-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
34 lines (22 loc) · 813 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
from fastapi import FastAPI
import webhandler
app = FastAPI()
webprocessing = webhandler.WebProcessor()
#domain where this api is hosted for example : localhost:5000/docs to see swagger documentation automagically generated.
@app.get("/")
def home():
return {"message":"debug test"}
@app.get("/ping/{url}")
async def pong(url: str):
data = webprocessing.getUrlData(url)
if data.get("error") != "none":
return {"Bad inputs" : data.get("error")}
return data
# return {
# "Headline": data.get("headline"),
# "readingscore": mainHeadlineScore,
# "relativeScore": relativeScore,
# "relatedScores": relatedScores
# }
# return {"Headline": data.get("headline"), "Headline2": data.get("relatedHeadlines")}
#uvicorn API:api --reload