Adding reqs

This commit is contained in:
Lucas
2021-07-18 14:04:17 -04:00
parent d49747a9e6
commit dfdffda31e
6 changed files with 83 additions and 34 deletions

21
requirements.txt Normal file
View 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

View File

@@ -3,6 +3,7 @@ import threading
from flask import Flask, jsonify, render_template, request from flask import Flask, jsonify, render_template, request
from mta_manager import MTA from mta_manager import MTA
from pprint import pprint from pprint import pprint
import pandas as pd
app = Flask(__name__) app = Flask(__name__)
app.secret_key = "SuperSecretDontEvenTryToGuessMeGGEZNoRe" app.secret_key = "SuperSecretDontEvenTryToGuessMeGGEZNoRe"
@@ -11,10 +12,15 @@ app._static_folder = os.path.abspath("templates/static/")
subway_data = {} subway_data = {}
stops = pd.read_csv("stops.txt")
@app.route("/", methods=["GET"]) @app.route("/", methods=["GET"])
def index(): def index():
title = "Create the input image" # TODO: Shove this into a sqlite database
return render_template("layouts/index.html", title=title) 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"]) @app.route("/mta_data", methods=["POST"])
@@ -24,17 +30,32 @@ def get_mta_data():
subway_data subway_data
) )
@app.route("/stops", methods=["GET"]) @app.route("/stops", methods=["GET"])
def get_routes(): def get_routes():
return jsonify() return jsonify()
if __name__ == "__main__": @app.route("/get_stop_id/<stop_name>", methods=["GET"])
api_key = os.getenv('MTA_API_KEY', '') def get_stop_id(stop_name):
mtaController = MTA( print(stop_name)
api_key, rows = stops.loc[stops["stop_name"] == stop_name]
["A", "C", "E", "1", "2", "3"], print(rows)
["127S", "127N", "A27N", "A27S"] 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): async def mta_callback(routes):
@@ -43,22 +64,22 @@ if __name__ == "__main__":
subway_data = mtaController.convert_routes_to_station_first(routes) 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(): def start_mta():
mtaController.add_callback(mta_callback) mtaController.add_callback(mta_callback)
mtaController.start_updates() 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() threadLock = threading.Lock()
threads = [threadWrapper(start_mta)] threads = [threadWrapper(start_mta, mtaController)]
for t in threads: for t in threads:
t.start() t.start()

View File

View File

@@ -27,6 +27,17 @@
<nav class="navbar navbar-dark bg-dark"> <nav class="navbar navbar-dark bg-dark">
<div class="container-fluid"> <div class="container-fluid">
<span class="navbar-brand mb-0 h1 station-name">Navbar</span> <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> </div>
</nav> </nav>
<div class="container-fluid content-row g-0"> <div class="container-fluid content-row g-0">

View File

@@ -18,6 +18,11 @@
float: right; float: right;
} }
.dropdown-menu {
max-height: 280px;
overflow-y: auto;
}
@media screen and (max-width: 1000px) { @media screen and (max-width: 1000px) {
.site-title { .site-title {

View File

@@ -1,9 +0,0 @@
import requests
headers = {
}
r = requests.get("http://localhost:58381/api/closures?BlockId=B445205")