Spaces:
Sleeping
Sleeping
| 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") | |
| 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} | |