show bus and passenger count in layerControl
This commit is contained in:
parent
cbbf56feed
commit
b7e2fb226e
2 changed files with 27 additions and 29 deletions
20
app.py
20
app.py
|
@ -1,14 +1,10 @@
|
|||
from flask import Flask, jsonify, render_template, send_from_directory
|
||||
from flask import Flask,render_template,send_from_directory
|
||||
from flask_caching import Cache
|
||||
import requests
|
||||
|
||||
app = Flask(__name__)
|
||||
|
||||
app.config['CACHE_TYPE'] = 'SimpleCache'
|
||||
cache = Cache(app)
|
||||
|
||||
data=requests.get("https://tarc.rideralerts.com/InfoPoint/rest/Routes/GetVisibleRoutes").json()
|
||||
routes=",".join(str(r.get('RouteId')) for r in data)
|
||||
app=Flask(__name__)
|
||||
app.config['CACHE_TYPE']='SimpleCache'
|
||||
cache=Cache(app)
|
||||
|
||||
@app.route("/")
|
||||
def index():
|
||||
|
@ -18,11 +14,11 @@ def index():
|
|||
def favicon():
|
||||
return send_from_directory(app.static_folder,"bus.svg")
|
||||
|
||||
@app.route('/tarc.csv')
|
||||
data=requests.get("https://tarc.rideralerts.com/InfoPoint/rest/Routes/GetVisibleRoutes").json()
|
||||
routes=",".join(str(r.get('RouteId')) for r in data)
|
||||
|
||||
@app.route("/tarc.csv")
|
||||
@cache.cached(timeout=5)
|
||||
def tarc():
|
||||
d=requests.get("https://tarc.rideralerts.com/InfoPoint/rest/Vehicles/GetAllVehiclesForRoutes?routeIDs="+routes).json()
|
||||
return "\n".join(f"{v['Latitude']},{v['Longitude']},{v['RouteId']},{v['Name']},{v['OnBoard']},{v['DirectionLong']},{v['Speed']},{v['LastUpdated'][6:16]}" for v in d)
|
||||
|
||||
if __name__ == '__main__':
|
||||
app.run()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue