-
VueJS widget that shows incoming bus schedules
-
Python/Flask proxy server for open.tan.fr APIs
-
Enable cross domain requests
-
Data consolidation
-
pip install --no-cache-dir -r requirements.txt
python run.py
This should serve the api at http://127.0.0.1:5000/ and the widget at http://127.0.0.1:5000/static/index.html, using the built-in dev server.
docker build -t wallboard-tan-back .
docker run -p 5000:5000 -it --rm wallboard-tan-back
This should serve the api at http://127.0.0.1:5000/ and the widget at http://127.0.0.1:5000/static/index.html, using production grade webserver.
Configuration can be changed with environment variables
WIDGET_BUS_API_URL
-
By default the preprod API from tan.fr is used (e.g. http://open_preprod.tan.fr) To switch to production environment, set the variable to http://open.tan.fr/ewp
WIDGET_BUS_LOG_LEVEL
-
Logging level (
DEBUG
,INFO
, etc.) The default value isINFO
.
To set the variables before calling the script:
WIDGET_BUS_LOG_LEVEL=DEBUG python run.py
Or with docker:
docker run -e "WIDGET_BUS_LOG_LEVEL=DEBUG" ✂
-p 5000:5000 -it --rm wallboard-tan-back
I ran across some issues, using the built-in dev server (werkzeug) under Windows:
-
ECMAScript files are served with
text/plain
mime type, which causes some browsers to reject them-
You have to update the
HKEY_CLASSES_ROOT\.js\Content-Type
registry entry totext/javascript
-
-
Server is slow when accessed via
localhost
, because of some IPv6 handling mess-
You have to either edit your IPv6 tables to use IPv4 binding for
localhost
:( -
Or access the server with
127.0.0.1
-
-
Threading has to be enabled (
threaded=True
inapp.run
)
You may not have those issues with Docker.
curl -i http://127.0.0.1:5000/theoretical?stop=IDNA&line=4&line=C5
Where:
- IDNA
-
stop identifier
- 4, C5
-
line numbers (multiple values accepted)
Returns
[{
stop: "IDNA",
direction: 1,
terminus: "Foch Cathétrale",
line: "4",
next_arrivals: [1.5, 3]
},
{
stop: "IDNA",
direction: 2,
terminus: "Porte de Vertou",
line: "4",
next_arrivals: [6, 8, 12]
}, ... ]
Some examples URI
Production:
Pre-production: