Upload app.py
Browse files
app.py
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from flask import Flask, request,render_template
|
2 |
+
from Model import SpellCheckerModule
|
3 |
+
|
4 |
+
app = Flask(__name__)
|
5 |
+
spell_checker_module = SpellCheckerModule()
|
6 |
+
|
7 |
+
# routes
|
8 |
+
@app.route('/')
|
9 |
+
def index():
|
10 |
+
return render_template('index.html')
|
11 |
+
@app.route('/spell',methods=['POST','GET'])
|
12 |
+
def spell():
|
13 |
+
if request.method=='POST':
|
14 |
+
text = request.form['text']
|
15 |
+
corrected_text = spell_checker_module.correct_spell(text)
|
16 |
+
corrected_grammar = spell_checker_module.correct_grammar(text)
|
17 |
+
return render_template('index.html',corrected_text=corrected_text,corrected_grammar=corrected_grammar)
|
18 |
+
@app.route('/grammar',methods=['POST','GET'])
|
19 |
+
def grammar():
|
20 |
+
if request.method == 'POST':
|
21 |
+
file = request.files['file']
|
22 |
+
readable_file = file.read().decode('utf-8',errors='ignore')
|
23 |
+
corrected_file_text = spell_checker_module.correct_spell(readable_file)
|
24 |
+
corrected_file_grammar = spell_checker_module.correct_grammar(readable_file)
|
25 |
+
return render_template('index.html',corrected_file_text=corrected_file_text,corrected_file_grammar=corrected_file_grammar)
|
26 |
+
|
27 |
+
# python main
|
28 |
+
if __name__ == "__main__":
|
29 |
+
app.run(debug=True)
|