|
from fastapi import FastAPI
|
|
|
|
|
|
def create_app() -> FastAPI:
|
|
|
|
app = FastAPI()
|
|
|
|
@app.get('/hello')
|
|
async def hello():
|
|
return {'hello': 'world'}
|
|
|
|
# startup e shutdown
|
|
@app.on_event('startup')
|
|
async def startup():
|
|
print('Iniciado')
|
|
# conecta com o banco de dados
|
|
|
|
@app.on_event('shutdown')
|
|
async def shutdown():
|
|
print('Finalizado')
|
|
# libera conexão com banco de dados
|
|
|
|
return app
|