from flask import Flask, render_template, Response
from blues import com, idc
import logging


def init() -> "Flask":
    logging.getLogger("ppocr").setLevel(logging.WARN)
    this = Flask(__name__)
    this.config["JSON_AS_ASCII"] = False
    this.config["TEMPLATES_AUTO_RELOAD"] = True

    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()
