File size: 2,107 Bytes
82fea0b
a0e09ac
0901162
 
 
 
e5097ae
574868c
82fea0b
18937a6
0901162
18937a6
0901162
 
 
 
 
e5097ae
4cc3235
0901162
 
 
574868c
0901162
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
06ea02e
 
26928da
0901162
 
 
73acaaa
0901162
18937a6
82fea0b
 
 
f1edda6
18937a6
82fea0b
 
 
0901162
 
 
3156c38
 
0901162
 
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
from fastapi import FastAPI,status,HTTPException,Request
# from .models import lr
import schemas
import Database
import models
import Cleaning
import pytz
from datetime import datetime
from firebase_admin import auth
from firebase_admin import firestore

db = firestore.client()

app=FastAPI()

@app.get('/')
def index():
    tz = pytz.timezone('Etc/GMT+3')
    return "This is the defult page"+str(datetime.now(tz))

@app.get('/reviews',status_code=status.HTTP_200_OK)
def get_reviews():
    return "Reviews"+str(datetime.today().date())

#Porcessing Shakwa
@app.post('/predict_summary')
async def get_reviews(request : schemas.shakwa):
    if 'text' in request:
        return models.modelsummary(request.complaintbody)
    else:
        raise HTTPException(status_code=status.HTTP_400_BAD_REQUEST, detail="Missing text value")
    
#Porcessing Feedback
@app.post('/predict_sentiment')
def get_reviews(request : schemas.feedback):
    if 'text' in request:
        return models.modelpredict(request.text)
    else:
        raise HTTPException(status_code=status.HTTP_400_BAD_REQUEST, detail="Missing mathod value")
    
@app.get("/emotionCount")
def getemotionCount():
    return Database.emotioncount
#Analysis
@app.get('/CommonWords')
def get_reviews():
    data=Database.shakwa_common_words()
    return data
@app.post("/updateuser")
async def updateuser(request: Request):
    json_data = await request.json()
    if("Uid"  in json_data and"email"  in json_data and "password"  in json_data ):
        user = auth.update_user( json_data["Uid"],email=json_data["email"],password=json_data["password"], )
        db.collection("users").document(json_data["Uid"]).update({"email":json_data["email"],"password":json_data["password"]})
        return('Sucessfully updated user: {0}'.format(user.uid))
    else:
        raise HTTPException(status_code=status.HTTP_400_BAD_REQUEST, detail="bad requast missing requied vaules")

@app.get('/CommonPlaces')
def get_reviews():
    # data={"Most Common Words":{"مدينة نصر":11,"الدقي":12}}
    data=Database.get_most_common_places()
    return data