Есть такой вопрос, код
from flask import Flask, render_template import datetime app = Flask(__name__) i = 0 @app.route("/") def hello(): now = datetime.datetime.now() timeString = now.strftime("%Y-%m-%d %H:%M") templateData = { 'title' : 'Stranica', 'time': timeString } return render_template('gpioweb.html', **templateData) @app.route("/all/off") def actionalloff(): global i i = i + 1 now = datetime.datetime.now() timeString = now.strftime("%Y-%m-%d %H:%M") message = "Najmite chtobi peregruzit." templateData = { 'title' : 'Stranica {0}'.format(i), 'message' : message, 'time' : timeString } return render_template('gpioweb.html', **templateData) if __name__ == "__main__": app.run(host='127.0.0.1', port=8001, debug=True)
и такой шаблон
<!DOCTYPE html> <head> <title>{{ title }}</title> <link rel="stylesheet" type="text/css" href="b.css"> <meta name="apple-mobile-web-app-title" content="RPi GPIO"> <meta name="apple-mobile-web-app-capable" content="yes"> <meta name="mobile-web-app-capable" content="yes"> <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent"> </head> <body> <h1>Pin Control</h1> <div id="buttons"> <a id="off" href="/all/off">All Off</a> <br /> <br /> </div> <br /> <br /> <p id="message"><span style="color:#E6A22E;">{{ time }}</span><span style="color:#2ED3E6;"><b> {{ message }}</b></span></p> <br /> <p id="time"><span style="color:#E6A22E;">Current server time: </span><span style="color:#2ED3E6;"><b>{{ time }}</b></span></p> </body> </html>
,а как сделать, что бы страница вызывалась и автоматически обновлялась, у пользователя в браузере при изменениях в программе а не при нажатии кнопки в браузере?
Например как сделать что бы каждую секунду появлялась новая страница с временем до секунды?