from flask import request from textblob import TextBlob from flask import app @app.route("/text/summarize", methods=["POST"]) def summarize(): text = request.json.get("text") return {"summary": TextBlob(text).summarize()} @app.route("/text/extract", methods=["POST"]) def extract(): text = request.json.get("text") return {"keywords": TextBlob(text).keywords} @app.route("/text/paraphrase", methods=["POST"]) def paraphrase(): text = request.json.get("text") return {"paraphrase": TextBlob(text).correct()} @app.route("/text/grammar", methods=["POST"]) def grammar(): text = request.json.get("text") return {"errors": TextBlob(text).spellcheck()} @app.route("/chat", methods=["POST"]) def chat(): prompt = request.json.get("prompt") #TODO: create chatting logic return {"response": f"prompt: {prompt}\nresponse: Still working on Text Generation logic, thanks for the patience!"}