Skip to content

Commit

Permalink
Merge pull request #3 from altf4arnold/flasktry
Browse files Browse the repository at this point in the history
Flask
  • Loading branch information
altf4arnold authored Mar 20, 2024
2 parents 2b69521 + be14909 commit 30bbaca
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 3 deletions.
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,11 @@ This program uses the API of Flightaware.
Said API requires an API key. More info [here](https://www.flightaware.com/commercial/aeroapi)

# Config.py :
The example file needs to be copied as config.py. There, you can configure the API key and airport that interests you.
The example file needs to be copied as config.py. There, you can configure the API key and airport that interests you.

# datapull.py :
This file will pull the data from flightaware's server and print it on the terminal

# Flask :
To start flask, ``flask run``
You can then go on ``https://127.0.0.1:5000``
21 changes: 21 additions & 0 deletions app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
"""
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'}
4 changes: 2 additions & 2 deletions datapull.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
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
Expand All @@ -27,7 +27,7 @@ def main():


if __name__ == '__main__':
departures = main()
departures = grabber()
name = "unknown"
operator = "unknown"
scheduled_off = "unknown"
Expand Down
Empty file added static/style.css
Empty file.
30 changes: 30 additions & 0 deletions templates/screen.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<link rel="stylesheet" href="style.css">
<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>

0 comments on commit 30bbaca

Please sign in to comment.