सामग्री पर जाएँ

निर्माणाधीन:फ्लास्क (पाइथन)/यूजर इनपुट

विकिविश्वविद्यालय से
<form name="form" method="post" action"" >
    <label for="name">Enter your name:</label>
    <input name="name" type="text">
    <input type="submit" value="Submit">
</form>
from flask import Flask, request, render_template

app = Flask(__name__)


@app.route('/', methods=['GET', 'POST'])
def root():
    if request.method == "GET":
        return render_template('index.html')
    elif request.method == "POST":
        return "Hello " + request.form['name'] + "!"
    else:
        return "Unexpected request.method: " + request.method


if __name__ == '__main__':
    app.run(host='0.0.0.0', port='5000')