Applied Programming/GUI/Python3/flask
Appearance
main.py
[edit | edit source]"""
reference: https://en.wikiversity.org/wiki/Flask/User_Input
"""
from flask import Flask
from flask import request
app = Flask(__name__, static_folder='.', root_path='/home/runner')
@app.route('/', methods=['GET'])
def root():
return app.send_static_file('./index.html')
@app.route('/', methods=['POST'])
def display():
return "Hello " + request.form['name'] + "!"
if __name__ == '__main__':
app.run(host='0.0.0.0', port='5000')
index.html
[edit | edit source]<form name="form" method="post" action"" >
<label for="name">Enter your name:</label>
<input name="name" type="text">
<input type="submit" value="Submit">
</form>