Exemple #1
0
def serve(create_db, with_fixtures, port, hot_reload):
    if create_db:
        if hot_reload:
            sys.exit("You must use the flag --no-hot-reload in order to create the database")
        init_db()
    if with_fixtures:
        if hot_reload:
            sys.exit("You must use the flag --no-hot-reload in order to load fixtures")
        fixtures()
    app = setup_app()
    from anillo import serving
    serving.run_simple(
            app,
            port=port,
            host=DEFAULT_HOST,
            autoreload=hot_reload)
Exemple #2
0
from anillo.app import application
from anillo.middlewares.json import wrap_json
from anillo.http import Ok

#
# You can test this example with the curl line:
#
# curl -X POST -d '{"echo": "Hello World"}' localhost:5000 -H "Content-Type: application/json"
#

def index(request):
    return Ok({"echo-response": request.body["echo"]}, headers={"Content-Type": "application/json"})


app = application(wrap_json(index))


if __name__ == '__main__':
    from anillo import serving
    serving.run_simple(app, port=5000)
Exemple #3
0
def runserver():
    app = setup_anillo_app()
    from anillo import serving
    serving.run_simple(app, port=5500, host='0.0.0.0', threaded=True)
Exemple #4
0
import sys
import os

sys.path.append(os.path.dirname(__file__))  # adding src directory to path


def setup_application():
    from anillo.app import application
    from anillo.utils import chain
    from anillo.middlewares.params import get_params_middleware
    from anillo.middlewares.json import json_middleware
    from anillo.middlewares.default_headers import default_headers_middleware
    from router import router
    handler = chain(
        get_params_middleware,
        json_middleware,
        default_headers_middleware({}, {
            "Content-Type": "application/json",
            "Access-Control-Allow-Origin": "*",
            "Access-Control-Allow-Headers": "Accept, Accept-Version, Content-Length, Content-MD5, Content-Type, Date, X-Api-Version".lower(),
        }),
        router
    )
    return application(handler)


if __name__ == '__main__':
    from anillo import serving
    app = setup_application()
    serving.run_simple(app, port=5000, host='0.0.0.0')
Exemple #5
0
def runserver():
    app = setup_application()
    from anillo import serving
    serving.run_simple(app, port=5000, host='0.0.0.0', threaded=True)