Spaces:
Sleeping
Sleeping
| from fastapi import APIRouter | |
| import sqlite3 | |
| from passlib.context import CryptContext | |
| from pydantic import BaseModel | |
| class DataType(BaseModel): | |
| Email:str | |
| Password:str | |
| Longtude:str | |
| Lattitude:str | |
| Day:str | |
| Houre:str | |
| UserAddLocationRouter=APIRouter(prefix="/Location") | |
| def adduser(Dat:DataType): | |
| try: | |
| State=False | |
| pwd_context=CryptContext(schemes=["bcrypt"],deprecated="auto") | |
| connect=sqlite3.connect("DataBase/DataBase.bd") | |
| cursor=connect.execute(f''' | |
| SELECT UserId,Password FROM Users where Email='{Dat.Email}' | |
| ''') | |
| Data=cursor.fetchall() | |
| if len(Data) !=0 : | |
| if Data[0][0]==None: | |
| return {"Status":True,"Message":"User Is Not Defined Before"} | |
| HasedPassword=Data[0][1] | |
| UserId=Data[0][0] | |
| State=Dat.Password==HasedPassword | |
| if State: | |
| connect.execute(f''' | |
| INSERT INTO TrackeringPoints (UserId,Longtude ,Lattitude,Day,Houre) VALUES ({UserId},{float(Dat.Longtude)},{float(Dat.Lattitude)},'{Dat.Day}','{Dat.Houre}') | |
| ''') | |
| connect.commit() | |
| connect.close() | |
| return {"State":True} | |
| else: | |
| return {"State":False} | |
| except Exception as e : | |
| return {"Status":False,"Message":e} | |