diff --git a/datapull.py b/datapull.py index 276093d..eba4bbf 100644 --- a/datapull.py +++ b/datapull.py @@ -5,7 +5,7 @@ import config import requests -def main(): +def grabber(): """ Main function to pull data from flightaware API. Mostly flightaware code with overhead. Will modify if needed :return: raw data @@ -27,7 +27,7 @@ def main(): if __name__ == '__main__': - departures = main() + departures = grabber() name = "unknown" operator = "unknown" scheduled_off = "unknown" diff --git a/server.py b/server.py new file mode 100644 index 0000000..ad7cbe9 --- /dev/null +++ b/server.py @@ -0,0 +1,19 @@ +""" +This piece of code was written by myself. Supposed to be a frontend for a web-page that will run on a raspi in kiosk mode +""" + +import datapull +from flask import Flask, render_template +from config import AIRPORT as airport + +app = Flask(__name__) +@app.route("/") +def hello_world(): + rawdata = datapull.grabber() + return render_template('screen.html', airport=airport, data=rawdata) + + +@app.route("/style.css") +def style(): + with open("static/style.css", "r") as f: + return f.read(), 200, {'Content-Type': 'text/css; charset=utf-8'} \ No newline at end of file diff --git a/static/style.css b/static/style.css new file mode 100644 index 0000000..e69de29 diff --git a/templates/screen.html b/templates/screen.html new file mode 100644 index 0000000..a3ce38b --- /dev/null +++ b/templates/screen.html @@ -0,0 +1,29 @@ + + + + + {{ airport }} Departure Schedule + + + + + + + + + + + + {% for flight in data%} + + + + + + + + + {% endfor %} +
FlightTimeDelayAirlineDestinationRemarks
{{ flight["ident"] }}{{ flight["scheduled_off"] }}{{ flight["departure_delay"] }}{{ flight["operator"] }}{{ flight["destination"]["name"] }}{{ flight["status"] }}
+ + \ No newline at end of file