smif.http_api package

Provide method for creating the smif app

For example, build the front end:

cd smif/app/
npm run build

Or to rebuild js/css on change:

npm run watch

Then run the server app in debug mode with environment variables:

FLASK_DEBUG=1 smif -v app -d src/smif/sample_project/

Or if backend debug mode is not needed, just use the smif CLI:

smif app -d ../sample_project

API commands can be operated without the front end

GET commands can be performed by going to the requested url:

firefox http://localhost:5000/api/v1/model_runs

POST/PUT commands on configurations can be performed by using the curl utilities under linux:

curl -d '{
    "name": "scenario_set",
    "description": "my description",
    "facets": []
}' -H "Content-Type: application/json" -X POST http://localhost:5000/api/v1/scenario_sets/

Actions are triggered by sending an empty POST:

curl -d '{}' http://localhost:5000/api/v1/model_runs/20170918_energy_water/start
smif.http_api.create_app(static_folder, template_folder, data_interface, scheduler)[source]

Create Flask app object

Submodules

smif.http_api.app module

smif.http_api.app.create_app(static_folder, template_folder, data_interface, scheduler)[source]

Create Flask app object

smif.http_api.crud module

HTTP API endpoint

smif.http_api.crud.check_timestamp(data)[source]

Check for timestamp and parse to datetime object

smif.http_api.crud.parse_exceptions(exception)[source]

Parse a group of exceptions so that it can be sent over the http-api

smif.http_api.register module

smif.http_api.register.register_api(app, view, endpoint, url, key='id', key_type='int', action=None, action_type=None)[source]

Register a MethodView as an endpoint with CRUD operations at a URL

smif.http_api.register.register_api_endpoints(app)[source]

Register API calls (using pluggable views)

smif.http_api.register.register_error_handlers(app)[source]

Handle expected errors

smif.http_api.register.register_routes(app)[source]

Register plain routing