first try at flask
This commit is contained in:
parent
2b695214ca
commit
dbc4ce3229
|
@ -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"
|
||||
|
|
19
server.py
Normal file
19
server.py
Normal file
|
@ -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'}
|
0
static/style.css
Normal file
0
static/style.css
Normal file
29
templates/screen.html
Normal file
29
templates/screen.html
Normal file
|
@ -0,0 +1,29 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>{{ airport }} Departure Schedule</title>
|
||||
</head>
|
||||
<body>
|
||||
<table>
|
||||
<tr>
|
||||
<th>Flight</th>
|
||||
<th>Time</th>
|
||||
<th>Delay</th>
|
||||
<th>Airline</th>
|
||||
<th>Destination</th>
|
||||
<th>Remarks</th>
|
||||
</tr>
|
||||
{% for flight in data%}
|
||||
<tr>
|
||||
<td>{{ flight["ident"] }}</td>
|
||||
<td>{{ flight["scheduled_off"] }}</td>
|
||||
<td>{{ flight["departure_delay"] }}</td>
|
||||
<td>{{ flight["operator"] }}</td>
|
||||
<td>{{ flight["destination"]["name"] }}</td>
|
||||
<td>{{ flight["status"] }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in a new issue