from fastapi import FastAPI,Request from fastapi.staticfiles import StaticFiles from fastapi.responses import JSONResponse from Router.AppRouter import MainRouter from sqlite3 import connect from os.path import exists from fastapi.middleware.cors import CORSMiddleware from passlib.context import CryptContext app=FastAPI() try: conn=connect("DataBase/DataBase.bd") conn.execute("PRAGMA foreign_keys=ON") conn.execute(''' create table if not exists Users (UserId int primary key ,Email text not null , UserName text not null, Job text not null, Phonenumber text not null, Place text not null, BDay text not null, Password Text Not Null); ''') conn.execute(''' create table if not exists TrackeringPoints (UserId int ,Longtude REAL not null ,Lattitude REAL Not Null ,Day text not null ,Houre text not null , foreign key (UserId) references Users(UserId)) ''') conn.execute(''' create table if not exists UserModelVersion (UserId int ,FaceModel INT not null ,IndoorModel INT Not Null, foreign key (UserId) references Users(UserId)) ''') conn.execute(''' create table if not exists UserItems ( UserId int , UserItemName TEXT not null, foreign key (UserId) references Users(UserId)) ''') conn.close() except Exception as e: print(e) app.mount("/static",StaticFiles(directory="./static"),name="static") app.add_middleware(CORSMiddleware, allow_origins=["*"], allow_credentials=True, allow_methods=["*"], allow_headers=["admin-email","admin-password","content-type"], ) app.include_router(MainRouter)