app.py
from flask import Flask
from flask import render_template
from flask import request
app = Flask(__name__)
@app.route('/hello')
@app.route('/hello/<username>')
def hello_world(username=None):
return render_template('hello.html', username=username)
@app.route('/post', methods=['POST', 'PUT'])
def show_post():
print(f'methods={request.method}')
return str(request.values)
if __name__ == '__main__':
app.run(host='127.0.0.1', port=5000, debug=True)
templates/hello.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Hello</title>
</head>
<body>
{% if username %}
Hello {{ username }}
{% else %}
Hello
{% endif %}
</body>
</html>