У меня ниже код
from flask import Flask, render_template, request
app = Flask(__name__)
import logging
@app.route("/")
def hello():
return "Hello csdfwe!"
@app.route('/test/')
def check():
return render_template('template.html')
@app.route('/result/', methods = ['GET', 'POST'])
def result():
print "*****", request.form, "******"
return render_template('template1.html')
@app.route('/result1/', methods = ['GET', 'POST'])
def result1():
return "Pressed OK"
if __name__ == "__main__":
app.run()
template1.html
- это
<html>
<body>
<form action = "{{ url_for('result') }}" method = "POST">
<p>Value1 <input type = "text" name = "Value1" /></p>
<p>Value2<input type ="text" name = "Value2" /></p>
<p>Charging Duration <input type ="text" name = "Charging_Duration" /></p>
<p><input type = "submit" value = "submit" name = "submit" /></p>
</form>
</body>
</html>
Запрос: в html-файле, как вы можете видеть, у меня разные текстовые поля для Value1 и Value2. Я хочу напечатать существующее значение value1, которое уже есть после текстового поля. Это означает, что шаблон покажет уже существующее значение, и пользователь может установить любое новое значение. Я не знаю, как получить значение из функции в HTML.
Пожалуйста, руководство