32 lines
784 B
Python
32 lines
784 B
Python
from fastapi.middleware.cors import CORSMiddleware
|
|
from common.config.site_settings import site_settings
|
|
|
|
|
|
def register(app):
|
|
app.debug = site_settings.DEBUG
|
|
app.title = site_settings.NAME
|
|
|
|
add_global_middleware(app)
|
|
|
|
# This hook ensures that a connection is opened to handle any queries
|
|
# generated by the request.
|
|
@app.on_event("startup")
|
|
async def startup():
|
|
pass
|
|
|
|
# This hook ensures that the connection is closed when we've finished
|
|
# processing the request.
|
|
@app.on_event("shutdown")
|
|
async def shutdown():
|
|
pass
|
|
|
|
|
|
def add_global_middleware(app):
|
|
app.add_middleware(
|
|
CORSMiddleware,
|
|
allow_origins=["*"],
|
|
allow_credentials=True,
|
|
allow_methods=["*"],
|
|
allow_headers=["*"],
|
|
)
|