Skip to content

SofteamOuest/wallboard-widget-bus

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

50 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Wallboard Bus Widget

  • VueJS widget that shows incoming bus schedules

  • Python/Flask proxy server for open.tan.fr APIs

    • Enable cross domain requests

    • Data consolidation

Run with python

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.

Run with docker

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.

Configure

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 is INFO.

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

Unit testing

python -m unittest

Notes on running dev server under Windows

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 to text/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 in app.run)

You may not have those issues with Docker.

Example API requests

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]
}, ... ]

About

Widget that shows incoming bus schedules

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published