import typing as t
import os

from flask import Flask
from flask import render_template
import werkzeug

APPPATH = os.path.dirname(os.path.abspath(__file__))
templates = os.path.join(APPPATH, "templates")
static = os.path.join(APPPATH, "static")


app = Flask(
    "Princely-Acts",
    template_folder=templates,
    static_folder=static,
    static_url_path=''
)


@app.errorhandler(404)
def page_not_found(e: werkzeug.exceptions.HTTPException) -> t.Tuple[t.Text, int]:
    return render_template("404.html", title="Page non trouvée"), 404


@app.errorhandler(500)
def internal_server_error(e: werkzeug.exceptions.HTTPException) -> t.Tuple[t.Text, int]:
    return render_template("500.html", title="Erreur interne du serveur"), 500


### DEBUG
@app.route('/')
@app.route('/index')
def hello_world():
    return "<p>Hello, World!</p>"
