kopia lustrzana https://github.com/glidernet/ogn-python
Use Bluepring
rodzic
9da595aa09
commit
965de93052
|
@ -21,4 +21,7 @@ migrate = Migrate(app, db)
|
|||
cache = Cache(app)
|
||||
celery = make_celery(app)
|
||||
|
||||
from app import routes, commands
|
||||
from app.main import bp as bp_main
|
||||
app.register_blueprint(bp_main)
|
||||
|
||||
from app import commands
|
||||
|
|
|
@ -1,90 +0,0 @@
|
|||
from flask import request, render_template, make_response, send_file
|
||||
from flask_cors import cross_origin
|
||||
|
||||
from app.backend.liveglidernet import rec, lxml
|
||||
|
||||
from app import app
|
||||
from app import db
|
||||
from app import cache
|
||||
|
||||
|
||||
@app.route("/live.html")
|
||||
@cross_origin()
|
||||
def live():
|
||||
return render_template("ogn_live.html", host=request.host)
|
||||
|
||||
|
||||
@app.route("/rec.php")
|
||||
def rec_php():
|
||||
a = request.args.get("a")
|
||||
z = request.args.get("z")
|
||||
|
||||
xml = rec()
|
||||
resp = app.make_response(xml)
|
||||
resp.mimetype = "text/xml"
|
||||
return resp
|
||||
|
||||
|
||||
@app.route("/lxml.php")
|
||||
def lxml_php():
|
||||
a = request.args.get("a")
|
||||
b = request.args.get("b")
|
||||
c = request.args.get("c")
|
||||
d = request.args.get("d")
|
||||
e = request.args.get("e")
|
||||
z = request.args.get("z")
|
||||
|
||||
xml = lxml()
|
||||
resp = app.make_response(xml)
|
||||
resp.mimetype = "text/xml"
|
||||
return resp
|
||||
|
||||
|
||||
@app.route("/pict/<filename>")
|
||||
def pict(filename):
|
||||
return app.send_static_file("ognlive/pict/" + filename)
|
||||
|
||||
|
||||
@app.route("/favicon.gif")
|
||||
def favicon_gif():
|
||||
return app.send_static_file("ognlive/pict/favicon.gif")
|
||||
|
||||
|
||||
@app.route("/horizZoomControl.js")
|
||||
def horizZoomControl_js():
|
||||
return app.send_static_file("ognlive/horizZoomControl.js")
|
||||
|
||||
|
||||
@app.route("/barogram.js")
|
||||
def barogram_js():
|
||||
return app.send_static_file("ognlive/barogram.js")
|
||||
|
||||
|
||||
@app.route("/util.js")
|
||||
def util_js():
|
||||
return app.send_static_file("ognlive/util.js")
|
||||
|
||||
|
||||
@app.route("/ogn.js")
|
||||
def ogn_js():
|
||||
return app.send_static_file("ognlive/ogn.js")
|
||||
|
||||
|
||||
@app.route("/ol.js")
|
||||
def ol_js():
|
||||
return app.send_static_file("ognlive/ol.js")
|
||||
|
||||
|
||||
@app.route("/osm.js")
|
||||
def osm_js():
|
||||
return app.send_static_file("ognlive/osm.js")
|
||||
|
||||
|
||||
@app.route("/ol.css")
|
||||
def ol_css():
|
||||
return app.send_static_file("ognlive/ol.css")
|
||||
|
||||
|
||||
@app.route("/osm.css")
|
||||
def osm_css():
|
||||
return app.send_static_file("ognlive/osm.css")
|
|
@ -0,0 +1,5 @@
|
|||
from flask import Blueprint
|
||||
|
||||
bp = Blueprint("main", __name__)
|
||||
|
||||
import app.main.routes
|
|
@ -0,0 +1,89 @@
|
|||
from flask import request, render_template, make_response, send_file, current_app
|
||||
from flask_cors import cross_origin
|
||||
|
||||
from app.backend.liveglidernet import rec, lxml
|
||||
from app import db
|
||||
from app import cache
|
||||
|
||||
from app.main import bp
|
||||
|
||||
@bp.route("/live.html")
|
||||
@cross_origin()
|
||||
def live():
|
||||
return render_template("ogn_live.html", host=request.host)
|
||||
|
||||
|
||||
@bp.route("/rec.php")
|
||||
def rec_php():
|
||||
a = request.args.get("a")
|
||||
z = request.args.get("z")
|
||||
|
||||
xml = rec()
|
||||
resp = current_app.make_response(xml)
|
||||
resp.mimetype = "text/xml"
|
||||
return resp
|
||||
|
||||
|
||||
@bp.route("/lxml.php")
|
||||
def lxml_php():
|
||||
a = request.args.get("a")
|
||||
b = request.args.get("b")
|
||||
c = request.args.get("c")
|
||||
d = request.args.get("d")
|
||||
e = request.args.get("e")
|
||||
z = request.args.get("z")
|
||||
|
||||
xml = lxml()
|
||||
resp = current_app.make_response(xml)
|
||||
resp.mimetype = "text/xml"
|
||||
return resp
|
||||
|
||||
|
||||
@bp.route("/pict/<filename>")
|
||||
def pict(filename):
|
||||
return current_app.send_static_file("ognlive/pict/" + filename)
|
||||
|
||||
|
||||
@bp.route("/favicon.gif")
|
||||
def favicon_gif():
|
||||
return current_app.send_static_file("ognlive/pict/favicon.gif")
|
||||
|
||||
|
||||
@bp.route("/horizZoomControl.js")
|
||||
def horizZoomControl_js():
|
||||
return current_app.send_static_file("ognlive/horizZoomControl.js")
|
||||
|
||||
|
||||
@bp.route("/barogram.js")
|
||||
def barogram_js():
|
||||
return current_app.send_static_file("ognlive/barogram.js")
|
||||
|
||||
|
||||
@bp.route("/util.js")
|
||||
def util_js():
|
||||
return current_app.send_static_file("ognlive/util.js")
|
||||
|
||||
|
||||
@bp.route("/ogn.js")
|
||||
def ogn_js():
|
||||
return current_app.send_static_file("ognlive/ogn.js")
|
||||
|
||||
|
||||
@bp.route("/ol.js")
|
||||
def ol_js():
|
||||
return current_app.send_static_file("ognlive/ol.js")
|
||||
|
||||
|
||||
@bp.route("/osm.js")
|
||||
def osm_js():
|
||||
return current_app.send_static_file("ognlive/osm.js")
|
||||
|
||||
|
||||
@bp.route("/ol.css")
|
||||
def ol_css():
|
||||
return current_app.send_static_file("ognlive/ol.css")
|
||||
|
||||
|
||||
@bp.route("/osm.css")
|
||||
def osm_css():
|
||||
return current_app.send_static_file("ognlive/osm.css")
|
|
@ -2,12 +2,12 @@ import datetime
|
|||
|
||||
from flask import request, render_template, send_file
|
||||
|
||||
from app import app
|
||||
from app import db
|
||||
from app import cache
|
||||
|
||||
from app.model import *
|
||||
|
||||
from app.main import bp
|
||||
|
||||
|
||||
@cache.cached(key_prefix="countries_in_receivers")
|
||||
def get_countries_in_receivers():
|
||||
|
@ -43,19 +43,19 @@ def get_dates_for_airport(sel_airport):
|
|||
return [{"date": date, "logbook_count": logbook_count} for (date, logbook_count) in query.all()]
|
||||
|
||||
|
||||
@app.route("/")
|
||||
@app.route("/index.html")
|
||||
@bp.route("/")
|
||||
@bp.route("/index.html")
|
||||
def index():
|
||||
return render_template("base.html")
|
||||
|
||||
|
||||
@app.route("/devices.html", methods=["GET", "POST"])
|
||||
@bp.route("/devices.html", methods=["GET", "POST"])
|
||||
def devices():
|
||||
devices = db.session.query(Device).order_by(Device.address).limit(100)
|
||||
return render_template("devices.html", devices=devices)
|
||||
|
||||
|
||||
@app.route("/device_detail.html", methods=["GET", "POST"])
|
||||
@bp.route("/device_detail.html", methods=["GET", "POST"])
|
||||
def device_detail():
|
||||
device_id = request.args.get("id")
|
||||
device = db.session.query(Device).filter(Device.id == device_id).one()
|
||||
|
@ -63,7 +63,7 @@ def device_detail():
|
|||
return render_template("device_detail.html", title="Device", device=device)
|
||||
|
||||
|
||||
@app.route("/receivers.html")
|
||||
@bp.route("/receivers.html")
|
||||
def receivers():
|
||||
sel_country = request.args.get("country")
|
||||
|
||||
|
@ -78,7 +78,7 @@ def receivers():
|
|||
return render_template("receivers.html", title="Receivers", sel_country=sel_country, countries=countries, receivers=receivers)
|
||||
|
||||
|
||||
@app.route("/receiver_detail.html")
|
||||
@bp.route("/receiver_detail.html")
|
||||
def receiver_detail():
|
||||
sel_receiver_id = request.args.get("receiver_id")
|
||||
|
||||
|
@ -98,7 +98,7 @@ def receiver_detail():
|
|||
return render_template("receiver_detail.html", title="Receiver Detail", receiver=receiver, airport=airport.first())
|
||||
|
||||
|
||||
@app.route("/airports.html", methods=["GET", "POST"])
|
||||
@bp.route("/airports.html", methods=["GET", "POST"])
|
||||
def airports():
|
||||
sel_country = request.args.get("country")
|
||||
|
||||
|
@ -114,7 +114,7 @@ def airports():
|
|||
return render_template("airports.html", sel_country=sel_country, countries=countries, airports=airports)
|
||||
|
||||
|
||||
@app.route("/airport_detail.html")
|
||||
@bp.route("/airport_detail.html")
|
||||
def airport_detail():
|
||||
sel_airport = request.args.get("airport")
|
||||
|
||||
|
@ -125,7 +125,7 @@ def airport_detail():
|
|||
return render_template("airport_detail.html", title="Airport Detail", airport=airport.one(), devices=devices)
|
||||
|
||||
|
||||
@app.route("/logbook.html", methods=["GET", "POST"])
|
||||
@bp.route("/logbook.html", methods=["GET", "POST"])
|
||||
def logbook():
|
||||
sel_country = request.args.get("country")
|
||||
sel_airport = request.args.get("airport")
|
||||
|
@ -175,7 +175,7 @@ def logbook():
|
|||
return render_template("logbook.html", title="Logbook", sel_country=sel_country, countries=countries, sel_airport=sel_airport, airports=airports, sel_date=sel_date, dates=dates, logbook=logbook)
|
||||
|
||||
|
||||
@app.route("/download.html")
|
||||
@bp.route("/download.html")
|
||||
def download_flight():
|
||||
from io import StringIO
|
||||
|
||||
|
@ -186,7 +186,7 @@ def download_flight():
|
|||
return send_file(buffer, as_attachment=True, attachment_filename="wtf.igc", mimetype="text/plain")
|
||||
|
||||
|
||||
@app.route("/statistics.html")
|
||||
@bp.route("/statistics.html")
|
||||
def statistics():
|
||||
|
||||
today = datetime.date.today()
|
|
@ -19,12 +19,12 @@
|
|||
</div>
|
||||
<div class="collapse navbar-collapse" id="bs-navbar-collapse-1">
|
||||
<ul class="nav navbar-nav">
|
||||
<li><a href="{{ url_for('index') }}">Home</a></li>
|
||||
<li><a href="{{ url_for('devices') }}">Devices</a></li>
|
||||
<li><a href="{{ url_for('receivers') }}">Receivers</a></li>
|
||||
<li><a href="{{ url_for('airports') }}">Airports</a></li>
|
||||
<li><a href="{{ url_for('logbook') }}">Logbook</a></li>
|
||||
<li><a href="{{ url_for('statistics') }}">Statistics</a></li>
|
||||
<li><a href="{{ url_for('main.index') }}">Home</a></li>
|
||||
<li><a href="{{ url_for('main.devices') }}">Devices</a></li>
|
||||
<li><a href="{{ url_for('main.receivers') }}">Receivers</a></li>
|
||||
<li><a href="{{ url_for('main.airports') }}">Airports</a></li>
|
||||
<li><a href="{{ url_for('main.logbook') }}">Logbook</a></li>
|
||||
<li><a href="{{ url_for('main.statistics') }}">Statistics</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
|
||||
{% for device in devices %}
|
||||
<tr>
|
||||
<td><a href="{{ url_for('device_detail', id=device.id) }}">{{ device.address }}</a></td>
|
||||
<td><a href="{{ url_for('main.device_detail', id=device.id) }}">{{ device.address }}</a></td>
|
||||
<td>{% if device.info is not none %}{{ device.info.registration }}{% else %} - {% endif %}</td>
|
||||
<td {% if device.software_version and device.software_version < 6.6 %}class="text-danger"{% endif %}>{% if device.software_version is not none %}{{ device.software_version }}{% else %} - {% endif %}</td>
|
||||
</tr>
|
||||
|
|
Ładowanie…
Reference in New Issue