Page MenuHomec4science

app.py
No OneTemporary

File Metadata

Created
Fri, Nov 8, 12:13
from flask import Flask, render_template, request
from transformers import pipeline, set_seed
generator = pipeline('text-generation', model='gpt2') # faster to load model outside the loop
app = Flask(__name__)
@app.route('/')
def home():
return render_template('home.html')
@app.route('/authors', methods=['GET', 'POST'])
def search_authors():
search_term = request.form["input"] # gets input from the user defined text.
res = generator(search_term, max_length=100, num_return_sequences=1)
return render_template('authors.html', res=res)
if __name__ == '__main__':
app.secret_key = 'mysecret'
app.run(port=5000, debug=True)

Event Timeline