API
- class succulent.api.SucculentAPI(config, host='0.0.0.0', port=8080, format='csv')
Bases:
objectSucculent API server.
- Parameters:
host (str) – The host address to run the API server.
port (int) – The port number to run the API server.
config (str) – Path to the configuration file.
format (str, optional) – The format of the data (‘csv’, ‘json’, ‘sqlite’, or ‘image’).
- host
The host address to run the API server.
- Type:
str
- port
The port number to run the API server.
- Type:
int
- config
Configuration file.
- Type:
dict
- format
The format of the data (‘csv’, ‘json’, ‘sqlite’, or ‘image’).
- Type:
str
- app
Flask application.
- Type:
Flask
- processing
Instance of the Processing class.
- Type:
- Configuration:
- max_content_length (int, optional): Maximum accepted size (in bytes)
of an incoming request body. Defaults to
DEFAULT_MAX_CONTENT_LENGTH(5 MB) when not set in the configuration file. Requests exceeding this size are rejected with a 413 response before being processed, to protect the server against oversized or flooding POST requests.
- data()
Display the stored data.
- Returns:
JSON response with the stored data.
- Return type:
Response
- export()
Export the stored data to a CSV file.
- index()
Generate index HTML page with information about the API.
- Returns:
HTML response with the index page.
- Return type:
Response
- measure()
Process the incoming request and store the timestamp.
- Returns:
JSON response with a success message and timestamp.
- Return type:
Response
- payload_too_large(error)
Handle requests whose body exceeds ‘MAX_CONTENT_LENGTH’.
- Parameters:
error (HTTPException) – The raised 413 error.
- Returns:
JSON response with an error message.
- Return type:
Response
- start()
Start the Flask application on the specified host and port.
- Returns:
None
- url()
Generate URL with parameters for measurements.
- Returns:
JSON response with the generated URL.
- Return type:
Response