-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
40 lines (30 loc) · 922 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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
from fastapi import FastAPI
from fastapi.responses import RedirectResponse
import uvicorn
import sys
import os
from fastapi.templating import Jinja2Templates
from starlette.responses import Response
from textSummarizer.pipeline.preditction import PredictionPipeline
#initialing fastAPi
text: str= "What is the text summarization?"
app= FastAPI()
@app.get("/", tags= ["authentication"])
async def index():
return RedirectResponse(url="/doc")
@app.get("/train")
async def training():
try:
os.system("Python main.py")
return Response("Training Successful !!")
except Exception as e:
return Response(f"Error Occured ! {e}")
@app.post("/predict")
async def predict_route(text):
try:
obj= PredictionPipeline()
text= obj.predict(text)
except Exception as e:
raise e
if __name__=="__main__":
uvicorn.run(app, host="0.0.0.0", port= 8080)