app may be overriden
Browse files
app.py
CHANGED
@@ -1,29 +1,33 @@
|
|
1 |
-
from flask import request
|
2 |
from textblob import TextBlob
|
3 |
-
from flask import app
|
4 |
|
5 |
-
|
|
|
|
|
6 |
def summarize():
|
7 |
text = request.json.get("text")
|
8 |
return {"summary": TextBlob(text).summarize()}
|
9 |
|
10 |
-
@
|
11 |
def extract():
|
12 |
text = request.json.get("text")
|
13 |
return {"keywords": TextBlob(text).keywords}
|
14 |
|
15 |
-
@
|
16 |
def paraphrase():
|
17 |
text = request.json.get("text")
|
18 |
return {"paraphrase": TextBlob(text).correct()}
|
19 |
|
20 |
-
@
|
21 |
def grammar():
|
22 |
text = request.json.get("text")
|
23 |
return {"errors": TextBlob(text).spellcheck()}
|
24 |
|
25 |
-
@
|
26 |
def chat():
|
27 |
prompt = request.json.get("prompt")
|
28 |
-
#TODO: create chatting logic
|
29 |
return {"response": f"prompt: {prompt}\nresponse: Still working on Text Generation logic, thanks for the patience!"}
|
|
|
|
|
|
|
|
1 |
+
from flask import Flask, request
|
2 |
from textblob import TextBlob
|
|
|
3 |
|
4 |
+
flask_app = Flask(__name__)
|
5 |
+
|
6 |
+
@flask_app.route("/text/summarize", methods=["POST"])
|
7 |
def summarize():
|
8 |
text = request.json.get("text")
|
9 |
return {"summary": TextBlob(text).summarize()}
|
10 |
|
11 |
+
@flask_app.route("/text/extract", methods=["POST"])
|
12 |
def extract():
|
13 |
text = request.json.get("text")
|
14 |
return {"keywords": TextBlob(text).keywords}
|
15 |
|
16 |
+
@flask_app.route("/text/paraphrase", methods=["POST"])
|
17 |
def paraphrase():
|
18 |
text = request.json.get("text")
|
19 |
return {"paraphrase": TextBlob(text).correct()}
|
20 |
|
21 |
+
@flask_app.route("/text/grammar", methods=["POST"])
|
22 |
def grammar():
|
23 |
text = request.json.get("text")
|
24 |
return {"errors": TextBlob(text).spellcheck()}
|
25 |
|
26 |
+
@flask_app.route("/chat", methods=["POST"])
|
27 |
def chat():
|
28 |
prompt = request.json.get("prompt")
|
29 |
+
# TODO: create chatting logic
|
30 |
return {"response": f"prompt: {prompt}\nresponse: Still working on Text Generation logic, thanks for the patience!"}
|
31 |
+
|
32 |
+
if __name__ == "__main__":
|
33 |
+
flask_app.run(host="0.0.0.0", port=7860)
|