getendpoints/src/app.py

29 lines
681 B
Python

from flask import Flask, render_template
from api import api
from config import API_HOST, DATABASE_URI
from db import get_endpoints_from_db, init_db
from register import register_service, unregister_service
app = Flask(__name__)
app.config["SQLALCHEMY_DATABASE_URI"] = DATABASE_URI
app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False
app.register_blueprint(api)
init_db(app)
@app.route("/")
def homepage():
endpoints = get_endpoints_from_db()
return render_template("index.html", endpoints=endpoints, api_host=API_HOST)
if __name__ == "__main__":
register_service()
try:
app.run(host="0.0.0.0", port=5000)
finally:
unregister_service()