-
Notifications
You must be signed in to change notification settings - Fork 3
/
main.py
40 lines (32 loc) · 991 Bytes
/
main.py
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
import requests
from fastapi import FastAPI
from backend_code.health_news.health_news import news
from backend_code.chatbot.chat import bot_name,get_response
import json
import random
import json
from pathlib import Path
import torch
from backend_code.chatbot.model import NeuralNet
from backend_code.chatbot.nltk_utils import bag_of_words, tokenize
with open("backend_code/doctors_list/UpdatingDoctors.json") as s:
doctors_list=s.read()
doctors_list=json.loads(doctors_list)
with open("backend_code/hospitals_list/hospitals_data.json") as s:
hospitals_data=s.read()
hospitals_data=json.loads(hospitals_data)
app=FastAPI()
@app.get("/news")
async def get_news():
data=news()
return data
@app.get("/doctors")
async def get_doctors():
return doctors_list
@app.get("/hospitals")
async def get_hospitals():
return hospitals_data
@app.get("/chatbot/{message}")
async def chatbot(message:str):
msg=f"{bot_name} : {get_response(message)}"
return msg