using the url_for for link generation
+27 −1 · 3 files changed
-
flask-blog.py+3 −1 -
templates/404.html+9 −0 -
templates/base.html+15 −0
@@ -39,7 +39,9 @@ def index(): return render_template('weather-average.html', city='Portland, OR', months=months, weather=weather, highlight=highlight) - +@app.errorhandler(404) +def not_found(e): + return render_template('404.html') if __name__ == '__main__': app.run(debug=True) @@ -0,0 +1,9 @@ +{% extends 'base.html' %} +{% import 'macros.html' as macros %} + +{% block title %}Not Found{% endblock %} + +{% block page_content %} + <h1>Not Found</h1> + <p><a href = "{{ url_for('index') }}">Return to home page</a></p> +{% endblock %} \ No newline at end of file @@ -0,0 +1,15 @@ +{% extends 'bootstrap/base.html' %} + +{% block navbar %} + <nav class="navbar navbar-inverse" role="navigation"> + <div class="container"> + <a class="navbar-brand" href="{{ url_for("index") }}">Weather</a> + </div> + </nav> +{% endblock %} + +{% block content %} + <div class="container"> + {% block page_content %}{% endblock %} + </div> +{% endblock %} \ No newline at end of file