Credbox commited on
Commit
9184e73
·
verified ·
1 Parent(s): 10ed436

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -0
app.py ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from fastapi import FastAPI
2
+ from pydantic import BaseModel
3
+ from fastapi.responses import JSONResponse
4
+ from Paraphrase import paraphrase_paragraph
5
+
6
+ app = FastAPI()
7
+
8
+ class Sentence(BaseModel):
9
+ sentence: str
10
+
11
+
12
+ @app.get("/")
13
+ def index():
14
+ return "OK"
15
+
16
+ @app.post("/rephrase")
17
+ def rephrase(sentence: Sentence):
18
+ try:
19
+ rephrase_text = paraphrase_paragraph(sentence.sentence)
20
+ return JSONResponse(status_code=200, content={"rephrased_sentence": rephrase_text})
21
+ except Exception as e:
22
+ return JSONResponse(status_code=422,content="Unable to rephrase")