Spaces:
Sleeping
Sleeping
| from fastapi import APIRouter | |
| from fastapi.responses import JSONResponse | |
| import sqlite3 | |
| from passlib.context import CryptContext | |
| from pydantic import BaseModel | |
| UserGetTrackingDateRouter=APIRouter(prefix="/Location") | |
| class Data(BaseModel): | |
| Email:str | |
| Password:str | |
| def adduser(Dat:Data): | |
| try: | |
| Email= Dat.Email | |
| Password=Dat.Password | |
| connect=sqlite3.connect("DataBase/DataBase.bd") | |
| State=False | |
| cursor=connect.execute(f''' | |
| SELECT UserId,Password FROM Users where Email='{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=Password==HasedPassword | |
| if State: | |
| cursor=connect.execute(f''' | |
| SELECT DISTINCT Day FROM TrackeringPoints WHERE UserId={UserId} | |
| ''') | |
| DataCollected=cursor.fetchall() | |
| if len(DataCollected)==0: | |
| DataCollected=[["Nodays Found"]] | |
| connect.close() | |
| return { | |
| "Status":True, | |
| "Data":DataCollected, | |
| } | |
| else: | |
| return {"State":False} | |
| except Exception as e : | |
| return {"Status":False,"Message":e} | |