408fde440d
Photograph/screenshot a boarding pass, decode its BCBP barcode (PDF417/ Aztec/QR/DataMatrix), fetch the historical flight track from FlightAware the day after the flight, stage it for review, and write it into AirTrail via its REST API on approval. ntfy notifications carry signed Approve/Deny/Investigate actions.
44 lines
947 B
Python
44 lines
947 B
Python
import logging
|
|
import os
|
|
|
|
from flask import Flask, redirect, send_from_directory, url_for
|
|
from waitress import serve
|
|
|
|
import config
|
|
import db
|
|
import routes_review
|
|
import routes_settings
|
|
import routes_upload
|
|
import scheduler
|
|
|
|
logging.basicConfig(level=logging.INFO)
|
|
|
|
|
|
def create_app() -> Flask:
|
|
config.ensure_dirs()
|
|
db.init_db()
|
|
|
|
app = Flask(__name__)
|
|
app.config["MAX_CONTENT_LENGTH"] = config.MAX_UPLOAD_MB * 1024 * 1024
|
|
|
|
app.register_blueprint(routes_upload.bp)
|
|
app.register_blueprint(routes_review.bp)
|
|
app.register_blueprint(routes_settings.bp)
|
|
|
|
@app.route("/")
|
|
def index():
|
|
return redirect(url_for("upload.upload"))
|
|
|
|
@app.route("/uploads/<path:name>")
|
|
def uploaded_file(name):
|
|
return send_from_directory(config.UPLOADS_DIR, name)
|
|
|
|
return app
|
|
|
|
|
|
app = create_app()
|
|
|
|
if __name__ == "__main__":
|
|
scheduler.start_background_thread()
|
|
serve(app, host="0.0.0.0", port=config.PORT)
|