from utils import conf
from blues import com, idc
from flask_cors import CORS
from flask import Flask, render_template, Response


def init() -> "Flask":
    this = Flask(__name__)
    CORS(this)
    this.config.from_object(conf)

    this.register_blueprint(com)
    this.register_blueprint(idc)

    return this


app = init()


@app.route("/")
def index():
    return render_template("navigate.html")


@app.route("/favicon.ico")
def icon():
    with open("static/html/favicon.png", "rb") as f:
        img = f.read()
        f.close()
    return Response(img, mimetype="image/x-png")


if __name__ == "__main__":
    app.run(host=conf.SERVER_HOST, port=conf.SERVER_PORT)
