32 lines
756 B
Python
32 lines
756 B
Python
# topology_api/app.py
|
|
from pathlib import Path
|
|
|
|
from flask import Flask, send_from_directory
|
|
from flask_cors import CORS
|
|
from topology_api.config import API_HOST, API_PORT, API_DEBUG
|
|
from topology_api.routes.snapshot import snapshot_bp
|
|
|
|
|
|
WIKI_DIR = Path(__file__).resolve().parents[1] / "data" / "wiki"
|
|
|
|
|
|
def create_app():
|
|
app = Flask(__name__)
|
|
CORS(app)
|
|
app.register_blueprint(snapshot_bp)
|
|
|
|
@app.route("/health")
|
|
def health():
|
|
return {"status": "ok"}
|
|
|
|
@app.route("/guanghan_topology_demo.html")
|
|
def topology_demo():
|
|
return send_from_directory(WIKI_DIR, "guanghan_topology_demo.html")
|
|
|
|
return app
|
|
|
|
|
|
if __name__ == "__main__":
|
|
app = create_app()
|
|
app.run(host=API_HOST, port=API_PORT, debug=API_DEBUG)
|