You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

19 lines
528 B

9 months ago
from flask import Flask, render_template, request
from models import WordFrequencyModel
app = Flask(__name__)
app.config['SECRET_KEY'] = 'your-secret-key'
@app.route('/')
def index():
return render_template('index.html')
@app.route('/count', methods=['POST'])
def count_words():
text = request.form.get('text', '').lower()
model = WordFrequencyModel()
top_words = model.get_top_n_words(text, 10)
return render_template('index.html', top_words=top_words)
if __name__ == '__main__':
app.run(debug=True)