Exemplo n.º 1
0

# http://4dm1n:[email protected]:8000/
USERNAME = "******"
PASSWORD = "******"
# SESSIONS_STORED = 1
SESSIONS_STORED = 3

app = FastAPI()
app.include_router(northwind_api_router, tags=["northwind"])
app.id = 0
app.persons = []
templates = Jinja2Templates(directory="templates")
app.secret_key = "vsd;lgj[op"
app.session_tokens = []
app.cookie_tokens = []
random.seed(datetime.now())
security = HTTPBasic()
app.acceptable_order = ["first_name", "last_name", "city"]


@app.on_event("startup")
async def startup():
    app.db_connection = sqlite3.connect("northwind.db")
    app.db_connection.text_factory = lambda b: b.decode(errors="ignore")  # northwind specific 


@app.on_event("shutdown")
async def shutdown():
    app.db_connection.close()