File size: 2,283 Bytes
c4dc0b3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
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)