-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
31 lines (27 loc) · 763 Bytes
/
Copy pathmain.py
File metadata and controls
31 lines (27 loc) · 763 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
from fastapi import FastAPI
from fastapi.security import HTTPBearer
from app.api.v1.router import router as api_v1_router
from app.db.session import engine
from app.models import auth
from sqlmodel import SQLModel
app = FastAPI(
title="Books_API",
version="1.0.0",
description="API de consulta de biblioteca de livros.",
swagger_ui_parameters={
'persistAuthorization': True
}
)
security = HTTPBearer()
# Inclue um informativo na rota principal
@app.get("/api/v1", tags=["Info"])
def api_v1_root():
return {
"name": "Books API",
"version": "v1",
"docs": "/docs"
}
app.include_router(api_v1_router, prefix="/api/v1")
@app.on_event("startup")
def on_startup():
SQLModel.metadata.create_all(engine)