Hello World Flask App


from flask import Flask, render_template, request

# Create a Flask app instance
app = Flask(__name__)

# Route for the home page
def home():
    return 'Hello, World!'

# Route for a simple form
@app.route('/form', methods=['GET', 'POST'])
def form():
    if request.method == 'POST':
        name = request.form.get('name')
        return f'Hello, {name}!'
    return render_template('form.html')

# Route with dynamic content
def greet(name):
    return f'Hello, {name}!'

# Run the app if this script is executed directly
if __name__ == '__main__':

Create templates/form.html:

<!DOCTYPE html>
    <title>Simple Form</title>
    <h1>Enter your name:</h1>
    <form method="POST" action="/form">
        <input type="text" name="name" required>
        <input type="submit" value="Submit">


flask --app=hello run