-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp.py
24 lines (20 loc) · 807 Bytes
/
app.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
from fastapi import FastAPI, HTTPException, Request
from fastapi.responses import PlainTextResponse
from webpage_summarizer import WebpageSummarizerAI
app = FastAPI()
@app.get("/")
def read_root():
return {
"message": "Welcome to the Webpage Summarizer API. To use this service, prepend the API URL to the website URL you want to summarize. For example, visit /summarize/?url=https://example.com."
}
@app.get("/summarize/", response_class=PlainTextResponse)
def summarize_url(request: Request):
url = request.query_params.get("url")
print("url--> ", url)
summarizer = WebpageSummarizerAI(web_site=url.strip())
print("--> Error")
result = summarizer.run()
return result
if __name__ == "__main__":
import uvicorn
uvicorn.run(app, host="0.0.0.0", port=8000)