Jump to content

Applied Programming/GUI/main.py

From Wikiversity

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')