All Downloads are FREE. Search and download functionalities are using the official Maven repository.

python-aiohttp.__init__main.mustache Maven / Gradle / Ivy

There is a newer version: 6.2.1.2
Show newest version
import os
import connexion
{{#featureCORS}}
import aiohttp_cors
{{/featureCORS}}

def main():
    options = {
        "swagger_ui": True
        }
    specification_dir = os.path.join(os.path.dirname(__file__), 'openapi')
    app = connexion.AioHttpApp(__name__, specification_dir=specification_dir, options=options)
    app.add_api('openapi.yaml',
                arguments={'title': '{{appName}}'},
                pythonic_params=True,
                pass_context_arg_name='request')

{{#featureCORS}}
    # Enable CORS for all origins.
    cors = aiohttp_cors.setup(app.app, defaults={
        "*": aiohttp_cors.ResourceOptions(
            allow_credentials=True,
            expose_headers="*",
            allow_headers="*",
        )
    })

    # Register all routers for CORS.
    for route in list(app.app.router.routes()):
        cors.add(route)

{{/featureCORS}}
    app.run(port={{serverPort}})




© 2015 - 2024 Weber Informatics LLC | Privacy Policy