Untitled
unknown
plain_text
a year ago
1.0 kB
15
Indexable
<!DOCTYPE html>
<html>
<head>
<title>Введи своє ім’я</title>
</head>
<body>
<h1>Форма</h1>
<form action="/greet" method="POST">
<label for="name">Твоє ім’я:</label>
<input type="text" id="name" name="name">
<button type="submit">Відправити</button>
</form>
</body>
</html>
from flask import Flask, render_template,request
app = Flask(__name__)
new_name = "Оля"
@app.route("/greet")
def greet():
return render_template ("greet.html", user_name = new_name)
@app.route("/")
def index():
new_list = ["Math", "Eng", "Python", "SQL"]
return render_template("index.html", subjects = new_list, name = new_name )
# @app.route('/')
# def index():
# return render_template('form.html')
@app.route("/greet", methods = ["POST"])
def greet():
user_name = request.form["name"]
return render_template("greet.html", user_name = user_name)
app.run()Editor is loading...
Leave a Comment