From 1ea0cf06b177b3fc236c1fa5a7112eb7ce0726e3 Mon Sep 17 00:00:00 2001 From: Skyler Mansfield Date: Wed, 6 Mar 2024 18:46:14 +0000 Subject: [PATCH] Add flask method view example challenge 3 --- challenge/templates/challenge3.html | 6 ++++++ challenge/templates/index.html | 1 + challenge/views/__init__.py | 1 + challenge/views/challenge_3.py | 8 ++++++++ 4 files changed, 16 insertions(+) create mode 100644 challenge/templates/challenge3.html create mode 100644 challenge/views/challenge_3.py diff --git a/challenge/templates/challenge3.html b/challenge/templates/challenge3.html new file mode 100644 index 0000000..6fa1609 --- /dev/null +++ b/challenge/templates/challenge3.html @@ -0,0 +1,6 @@ +{% extends 'layout.html' %} + +{% block content %} +

Challenge 3

+

This is an example using a flask method view to render a template

+{% endblock %} diff --git a/challenge/templates/index.html b/challenge/templates/index.html index ff887f4..b967fc9 100644 --- a/challenge/templates/index.html +++ b/challenge/templates/index.html @@ -8,6 +8,7 @@

Challenges

{% endblock %} diff --git a/challenge/views/__init__.py b/challenge/views/__init__.py index 37c9efc..40a02e6 100644 --- a/challenge/views/__init__.py +++ b/challenge/views/__init__.py @@ -5,6 +5,7 @@ from . import ( challenge_1, # noqa: F401 challenge_2, # noqa: F401 + challenge_3, # noqa: F401 ) diff --git a/challenge/views/challenge_3.py b/challenge/views/challenge_3.py new file mode 100644 index 0000000..d179a9d --- /dev/null +++ b/challenge/views/challenge_3.py @@ -0,0 +1,8 @@ +from flask import render_template + +from challenge import app + + +@app.route("/3/", methods=["GET", "POST"]) +def challenge_3() -> str: + return render_template("challenge3.html")