Spaces:
Sleeping
Sleeping
File size: 1,499 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 |
from fastapi import APIRouter
import pandas as read_csv
from sqlite3 import connect
from os.path import isfile
from pydantic import BaseModel
class DataType(BaseModel):
label:str
Email:str
Password:str
IndoorLabel=APIRouter(prefix="/Uploader")
@IndoorLabel.post("/AddWiFiLAbel")
async def FunctionName(Data:DataType):
try:
con=connect("DataBase/DataBase.bd")
cursor=con.execute(f'''
SELECT UserId,Password FROM Users where Email='{Data.Email}'
''')
if len(cursor.fetchall())==1:
HasedPassword=cursor.fetchall()[0][1]
UserId=cursor.fetchall()[0][0]
State=Data.Password==HasedPassword
con.close()
if State:
if not isfile(f"./IndoorLocalization/Data/{UserId}/Data.csv"):
return {"Status":False,"message":"Cant Find DataSet"}
Labels=map(lambda x:int(x),Data.label.split(sep=","))
DATA=read_csv(f"./IndoorLocalization/Data/{UserId}/Data.csv")
DATA.loc[DATA.shape[0]]=Labels
DATA.to_csv(f"./IndoorLocalization/Data/{UserId}/Data.csv",index=False)
return {"Status":True,"message":"Store Done "}
else:
return {"Status":False,"Message":"Email or Password is not correct"}
except Exception as e:
return {"Status":False,"message":e}
|