|
from fastapi import FastAPI,status,HTTPException,Request |
|
|
|
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()) |
|
|
|
|
|
@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") |
|
|
|
|
|
@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 |
|
|
|
@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=Database.get_most_common_places() |
|
return data |
|
|
|
|