|
from quart import Quart
|
|
|
|
|
|
def create_app() -> Quart:
|
|
'''
|
|
Application factory pattern
|
|
'''
|
|
app = Quart(__name__)
|
|
|
|
# rotas
|
|
@app.route('/hello')
|
|
async def hello():
|
|
return {'hello': 'world'}
|
|
|
|
# startup e shutdown
|
|
@app.before_serving
|
|
async def startup():
|
|
print('Iniciado')
|
|
# conecta com o banco de dados
|
|
|
|
@app.after_serving
|
|
async def shutdown():
|
|
print('Finalizado')
|
|
# libera conexão com banco de dados
|
|
|
|
return app
|