diff --git a/hello.py b/hello.py index 62ab3a3..83940c1 100644 --- a/hello.py +++ b/hello.py @@ -6,11 +6,21 @@ app = Flask(__name__) bootstrap = Bootstrap(app) +@app.errorhandler(404) +def page_not_found(e): + return render_template('404.html'), 404 + + +@app.errorhandler(500) +def internal_server_error(e): + return render_template('500.html'), 500 + + @app.route('/') def index(): - return render_template('index.html') + return render_template('index.html') @app.route('/user/') def user(name): - return render_template('user.html', name=name) + return render_template('user.html', name=name) diff --git a/templates/404.html b/templates/404.html new file mode 100644 index 0000000..32b50c6 --- /dev/null +++ b/templates/404.html @@ -0,0 +1,9 @@ +{% extends "base.html" %} + +{% block title %}Flasky - Page not found{% endblock %} + +{% block page_content %} + +{% endblock %} \ No newline at end of file diff --git a/templates/500.html b/templates/500.html new file mode 100644 index 0000000..517f21a --- /dev/null +++ b/templates/500.html @@ -0,0 +1,9 @@ +{% extends "base.html" %} + +{% block title %}Flasky - Internal server error{% endblock %} + +{% block page_content %} + +{% endblock %} \ No newline at end of file diff --git a/templates/base.html b/templates/base.html new file mode 100644 index 0000000..fab11b8 --- /dev/null +++ b/templates/base.html @@ -0,0 +1,31 @@ +{% extends "bootstrap/base.html" %} + +{% block title %}Flasky{% endblock %} + +{% block navbar %} + +{% endblock %} + +{% block content %} +
+ {% block page_content %}{% endblock %} +
+{% endblock %} \ No newline at end of file diff --git a/templates/index.html b/templates/index.html index ba7c290..122059b 100644 --- a/templates/index.html +++ b/templates/index.html @@ -1 +1,9 @@ -

Hello World!

\ No newline at end of file +{% extends "base.html" %} + +{% block title %}Flasky{% endblock %} + +{% block page_content %} + +{% endblock %} \ No newline at end of file diff --git a/templates/user.html b/templates/user.html index 6bb1462..5fe92ee 100644 --- a/templates/user.html +++ b/templates/user.html @@ -1,33 +1,9 @@ -{% extends "bootstrap/base.html" %} +{% extends "base.html" %} {% block title %}Flasky{% endblock %} -{% block navbar %} -