'How to make the Flask app working in real time with two pages one page for data entry and another for display concurrently?
I have a flask app to enter data by a person through a page and display through another page to all. This is done with following as app.py
from flask import Flask, render_template, request, jsonify, url_for, redirect
app = Flask(__name__)
@app.route('/', methods = ['GET', 'POST'])
def index():
if request.method == 'POST':
date = request.form.get('date')
return redirect(url_for('booking', date=date))
return render_template('index.html')
@app.route('/display')
def booking():
date = request.args.get('date', None)
return render_template('display.html', date=date)
if __name__ == '__main__':
app.run(debug=True)
with index.html:
<html>
<head></head>
<body>
<h3>Home page</h3>
<form action="/" method="post">
<label for="date">Date: </label>
<input type="date" id="date" name="date">
<input type="submit" value="Submit">
</form>
</body>
</html>
with display.html:
<html>
<head></head>
<body>
<h3>Date display</h3>
<p>
Seleted date: {{ date }}
</p>
</body>
</html>
Now what happens is upon selecting a date in index.html, upon submitting, users are taken to display.html with date value in url and displayed. But what I want is the display page should independently display the data whatever is entered through index.html dynamically. My app requires data entry will be done by one person and display will be seen by rest all in real time. Is this possible?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
