region:us
---
license: from flask import Flask, render_template, request
from transformers import pipeline

app = Flask(__name__)

# Load the model from Hugging Face
model = pipeline("text-generation", model="distilgpt2")

@app.route("/", methods=["GET", "POST"])
def index():
    if request.method == "POST":
        # Get user input
        prompt = request.form["prompt"]
        # Generate text based on user input
        generated_text = model(prompt, max_length=50, do_sample=True)[0]['generated_text']
        return render_template("index.html", prompt=prompt, generated_text=generated_text)
    return render_template("index.html")

if __name__ == "__main__":
    app.run(debug=True)

