youssef1214 commited on
Commit
18937a6
·
1 Parent(s): 82fea0b

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +4 -2
main.py CHANGED
@@ -7,8 +7,9 @@ import Cleaning
7
  import pytz
8
  from datetime import datetime
9
  from firebase_admin import auth
 
10
 
11
-
12
 
13
  app=FastAPI()
14
 
@@ -45,7 +46,7 @@ def getemotionCount():
45
  def get_reviews():
46
  data=Database.shakwa_common_words()
47
  return data
48
- @app.post("/updateuser"):
49
  async def updateuser(request: Request):
50
  json_data = await request.json()
51
  if("Uid" in json_data and"email" in json_data and "password" in json_data ):
@@ -54,6 +55,7 @@ async def updateuser(request: Request):
54
  email=json_data["email"],
55
  password=json_data["password"],
56
  )
 
57
  return('Sucessfully updated user: {0}'.format(user.uid))
58
  else:
59
  raise HTTPException(status_code=status.HTTP_400_BAD_REQUEST, detail="bad requast missing requied vaules")
 
7
  import pytz
8
  from datetime import datetime
9
  from firebase_admin import auth
10
+ from firebase_admin import firestore
11
 
12
+ db = firestore.client()
13
 
14
  app=FastAPI()
15
 
 
46
  def get_reviews():
47
  data=Database.shakwa_common_words()
48
  return data
49
+ @app.post("/updateuser")
50
  async def updateuser(request: Request):
51
  json_data = await request.json()
52
  if("Uid" in json_data and"email" in json_data and "password" in json_data ):
 
55
  email=json_data["email"],
56
  password=json_data["password"],
57
  )
58
+ db.collection("users").document(json_data["Uid"]).update({"email":json_data["email"],"password":json_data["password"]})
59
  return('Sucessfully updated user: {0}'.format(user.uid))
60
  else:
61
  raise HTTPException(status_code=status.HTTP_400_BAD_REQUEST, detail="bad requast missing requied vaules")