MyserviceΒΆ
myservice is a simple JSON Flask application that uses Flakon.
The application is created with flakon.create_app()
:
import os
from flakon import create_app
from myservice.views import blueprints
_HERE = os.path.dirname(__file__)
_SETTINGS = os.path.join(_HERE, 'settings.ini')
app = create_app(blueprints=blueprints, settings=_SETTINGS)
The settings.ini
file which is passed to create_app()
contains options for running the Flask app, like the DEBUG flag:
[flask]
DEBUG = true
Blueprint are imported from myservice.views
and one
Blueprint and view example was provided in myservice/views/home.py
:
from flakon import JsonBlueprint
home = JsonBlueprint('home', __name__)
@home.route('/')
def index():
"""Home view.
This view will return an empty JSON mapping.
"""
return {}
Views can return simple mappings (as highlighted in the example above), in that case they will be converted into a JSON response.