main.py
from flask import Flask, render_template, url_for, request
application = Flask(__name__)
@application.route('/',methods=['GET','POST'])
def index():
if request.method=='POST':
nama = request.form['nama']
email = request.form['email']
return render_template('display.html',nama=nama,email=email)
return render_template('index.html')
if __name__ == '__main__':
application.run(host='0.0.0.0',debug=True,port=8080)
index.html
<!DOCTYPE html>
<html>
<head>
<title>Web App Python Learning</title>
</head>
<body>
<form action="/" method="POST">
Nama :<br>
<input type="text" name="nama"><br>
Email : <br>
<input type="email" name="email"><br> <br>
<input type="submit" value="Submit">
</form>
</body>
</html>
display.html
<!DOCTYPE html>
<html>
<head>
<title>Web Python Learning</title>
</head>
<body>
<h2>Data Display</h2><br>
Name: {{ nama }}<br>
Email : {{ email }}
</html>
Next