from flask import Flask, request, jsonify from flask_cors import CORS from gramformer import Gramformer from autocorrect import Speller app = Flask(__name__) CORS(app) def process(text): gf = Gramformer(models=1, use_gpu=False) spell = Speller() corrected = spell(text) ans = "" res = gf.correct(corrected) for ele in res: ans += ele return ans @app.route('/', methods=["POST"]) def post(): data = request.get_json() res = process(data["text"]) return res if __name__ == '__main__': app.run(host="0.0.0.0", port=4000)