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

विकिविश्वविद्यालय से
Jump to navigation Jump to search

static/index.html[स्रोत सम्पादित करें]

<form name="form" method="post" action"" >
    <label for="name">Enter your name:</label>
    <input name="name" type="text">
    <input type="submit" value="Submit">

app.py[स्रोत सम्पादित करें]

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'] + "!"
        return "Unexpected request.method: " + request.method

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