Adding reqs
This commit is contained in:
21
requirements.txt
Normal file
21
requirements.txt
Normal file
@@ -0,0 +1,21 @@
|
||||
certifi==2020.12.5
|
||||
chardet==4.0.0
|
||||
click==8.0.1
|
||||
colorama==0.4.4
|
||||
Flask==2.0.1
|
||||
gtfs-realtime-bindings==0.0.7
|
||||
idna==2.10
|
||||
itsdangerous==2.0.1
|
||||
Jinja2==3.0.1
|
||||
MarkupSafe==2.0.1
|
||||
numpy==1.21.0
|
||||
pandas==1.3.0
|
||||
protobuf==3.16.0
|
||||
protobuf3-to-dict==0.1.5
|
||||
python-dateutil==2.8.1
|
||||
python-dotenv==0.17.1
|
||||
pytz==2021.1
|
||||
requests==2.25.1
|
||||
six==1.16.0
|
||||
urllib3==1.26.4
|
||||
Werkzeug==2.0.1
|
||||
59
server.py
59
server.py
@@ -3,6 +3,7 @@ import threading
|
||||
from flask import Flask, jsonify, render_template, request
|
||||
from mta_manager import MTA
|
||||
from pprint import pprint
|
||||
import pandas as pd
|
||||
|
||||
app = Flask(__name__)
|
||||
app.secret_key = "SuperSecretDontEvenTryToGuessMeGGEZNoRe"
|
||||
@@ -11,10 +12,15 @@ app._static_folder = os.path.abspath("templates/static/")
|
||||
|
||||
subway_data = {}
|
||||
|
||||
stops = pd.read_csv("stops.txt")
|
||||
|
||||
|
||||
@app.route("/", methods=["GET"])
|
||||
def index():
|
||||
title = "Create the input image"
|
||||
return render_template("layouts/index.html", title=title)
|
||||
# TODO: Shove this into a sqlite database
|
||||
station_names = sorted(list(set(stops["stop_name"].to_list())))
|
||||
print(station_names)
|
||||
return render_template("layouts/index.html", station_names=station_names)
|
||||
|
||||
|
||||
@app.route("/mta_data", methods=["POST"])
|
||||
@@ -24,17 +30,32 @@ def get_mta_data():
|
||||
subway_data
|
||||
)
|
||||
|
||||
|
||||
@app.route("/stops", methods=["GET"])
|
||||
def get_routes():
|
||||
return jsonify()
|
||||
|
||||
if __name__ == "__main__":
|
||||
api_key = os.getenv('MTA_API_KEY', '')
|
||||
mtaController = MTA(
|
||||
api_key,
|
||||
["A", "C", "E", "1", "2", "3"],
|
||||
["127S", "127N", "A27N", "A27S"]
|
||||
)
|
||||
@app.route("/get_stop_id/<stop_name>", methods=["GET"])
|
||||
def get_stop_id(stop_name):
|
||||
print(stop_name)
|
||||
rows = stops.loc[stops["stop_name"] == stop_name]
|
||||
print(rows)
|
||||
return str(rows)
|
||||
|
||||
|
||||
|
||||
def ack():
|
||||
print('message was received!')
|
||||
|
||||
|
||||
class threadWrapper(threading.Thread):
|
||||
def __init__(self, run, controller):
|
||||
threading.Thread.__init__(self)
|
||||
self.run = run
|
||||
self.controller = controller
|
||||
|
||||
def run(self):
|
||||
self.run()
|
||||
|
||||
|
||||
async def mta_callback(routes):
|
||||
@@ -43,22 +64,22 @@ if __name__ == "__main__":
|
||||
subway_data = mtaController.convert_routes_to_station_first(routes)
|
||||
|
||||
|
||||
class threadWrapper(threading.Thread):
|
||||
def __init__(self, run):
|
||||
threading.Thread.__init__(self)
|
||||
self.run = run
|
||||
|
||||
def run(self):
|
||||
self.run()
|
||||
|
||||
|
||||
def start_mta():
|
||||
mtaController.add_callback(mta_callback)
|
||||
mtaController.start_updates()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
api_key = os.getenv('MTA_API_KEY', '')
|
||||
mtaController = MTA(
|
||||
# TODO: Update to only work with station names - need to be able to transfer the station names to train lines -
|
||||
# maybe with polling the station ids to see what train lines come up?
|
||||
api_key,
|
||||
["A", "C", "E", "1", "2", "3"],
|
||||
["127S", "127N", "A27N", "A27S"]
|
||||
)
|
||||
threadLock = threading.Lock()
|
||||
threads = [threadWrapper(start_mta)]
|
||||
threads = [threadWrapper(start_mta, mtaController)]
|
||||
|
||||
for t in threads:
|
||||
t.start()
|
||||
|
||||
@@ -27,6 +27,17 @@
|
||||
<nav class="navbar navbar-dark bg-dark">
|
||||
<div class="container-fluid">
|
||||
<span class="navbar-brand mb-0 h1 station-name">Navbar</span>
|
||||
<div class="dropdown">
|
||||
<button class="btn btn-secondary dropdown-toggle" type="button" id="dropdownMenuButton2"
|
||||
data-bs-toggle="dropdown" aria-expanded="false">
|
||||
Dropdown button
|
||||
</button>
|
||||
<ul class="dropdown-menu dropdown-menu-dark" aria-labelledby="dropdownMenuButton2">
|
||||
{% for item in station_names %}
|
||||
<li><a class="dropdown-item" href="/get_stop_id/{{ item }}">{{ item }}</a></li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
<div class="container-fluid content-row g-0">
|
||||
|
||||
@@ -18,6 +18,11 @@
|
||||
float: right;
|
||||
}
|
||||
|
||||
.dropdown-menu {
|
||||
max-height: 280px;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
|
||||
@media screen and (max-width: 1000px) {
|
||||
.site-title {
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
import requests
|
||||
|
||||
|
||||
headers = {
|
||||
|
||||
}
|
||||
r = requests.get("http://localhost:58381/api/closures?BlockId=B445205")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user