From 582fca2e90033c50dea3d60e61647015a1e46f69 Mon Sep 17 00:00:00 2001 From: Rich Date: Sat, 3 Jul 2021 08:17:46 +0100 Subject: [PATCH] . --- Pipenv | 19 ------------------- Pipfile | 2 ++ Pipfile.lock | 25 ++++++++++++++++++++++++- app/__init__.py | 1 + app/forms.py | 10 ++++++++++ app/routes.py | 8 +++++++- app/templates/index.html | 20 ++++++++++++++++++++ 7 files changed, 64 insertions(+), 21 deletions(-) delete mode 100644 Pipenv create mode 100644 app/forms.py create mode 100644 app/templates/index.html diff --git a/Pipenv b/Pipenv deleted file mode 100644 index d3be19c..0000000 --- a/Pipenv +++ /dev/null @@ -1,19 +0,0 @@ -[[source]] -url = "https://pypi.org/simple" -verify_ssl = true -name = "pypi" - -[packages] -flask = "*" - -[dev-packages] -pylint = "*" -flake8 = "*" -yapf = "*" -black = "*" - -[requires] -python_version = "3.8" - -[pipenv] -allow_prereleases = true diff --git a/Pipfile b/Pipfile index d3be19c..e2ebbd8 100644 --- a/Pipfile +++ b/Pipfile @@ -5,6 +5,8 @@ name = "pypi" [packages] flask = "*" +flask_wtf = "*" +flask-login = "*" [dev-packages] pylint = "*" diff --git a/Pipfile.lock b/Pipfile.lock index e30257d..54ef572 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -1,7 +1,7 @@ { "_meta": { "hash": { - "sha256": "52e9358ee91840925689af9f58eeb06f9ed43e59d78d635179330809c6a53afa" + "sha256": "6f468a10e748aa502127b19811e3cb91bc60a239cbe1c6fa7cc3d0a90dc9ab30" }, "pipfile-spec": 6, "requires": { @@ -31,6 +31,22 @@ "index": "pypi", "version": "==2.0.1" }, + "flask-login": { + "hashes": [ + "sha256:6d33aef15b5bcead780acc339464aae8a6e28f13c90d8b1cf9de8b549d1c0b4b", + "sha256:7451b5001e17837ba58945aead261ba425fdf7b4f0448777e597ddab39f4fba0" + ], + "index": "pypi", + "version": "==0.5.0" + }, + "flask-wtf": { + "hashes": [ + "sha256:6ff7af73458f182180906a37a783e290bdc8a3817fe4ad17227563137ca285bf", + "sha256:ff177185f891302dc253437fe63081e7a46a4e99aca61dfe086fb23e54fff2dc" + ], + "index": "pypi", + "version": "==0.15.1" + }, "itsdangerous": { "hashes": [ "sha256:5174094b9637652bdb841a3029700391451bd092ba3db90600dea710ba28e97c", @@ -90,6 +106,13 @@ "sha256:6c1ec500dcdba0baa27600f6a22f6333d8b662d22027ff9f6202e3367413caa8" ], "version": "==2.0.1" + }, + "wtforms": { + "hashes": [ + "sha256:7ee6e0591777e4ad6779276cd64464bd0a8fc1ce2509b5bb88f936c9426c180c", + "sha256:cf01f0173ff7124ab30afeee444876a0f576fa5ed9c32f2112c439137077492f" + ], + "version": "==3.0.0a1" } }, "develop": { diff --git a/app/__init__.py b/app/__init__.py index 96c8ef5..8c19e77 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -1,5 +1,6 @@ from flask import Flask app = Flask(__name__) +app.config["SECRET_KEY"] = "fdsaGHJ768fdsGHKJHG656&*(&%&*(fsd" from app import routes diff --git a/app/forms.py b/app/forms.py new file mode 100644 index 0000000..55a4d2d --- /dev/null +++ b/app/forms.py @@ -0,0 +1,10 @@ +from flask_wtf import FlaskForm +from wtforms import StringField, PasswordField, BooleanField, SubmitField +from wtforms.validators import DataRequired + + +class LoginForm(FlaskForm): + username = StringField("Username", validators=[DataRequired()]) + password = PasswordField("Password", validators=[DataRequired()]) + remember_me = BooleanField("Remember Me") + submit = SubmitField("Sign In") diff --git a/app/routes.py b/app/routes.py index ff4ac11..312d8d1 100644 --- a/app/routes.py +++ b/app/routes.py @@ -1,7 +1,13 @@ +from flask import render_template from app import app @app.route("/") @app.route("/index") def index(): - return "Hello, World!" + user = {"username": "Miguel"} + posts = [ + {"author": {"username": "John"}, "body": "Beautiful day in Portland!"}, + {"author": {"username": "Susan"}, "body": "The Avengers movie was so cool!"}, + ] + return render_template("index.html", title="Home", user=user, posts=posts) diff --git a/app/templates/index.html b/app/templates/index.html new file mode 100644 index 0000000..21e71b1 --- /dev/null +++ b/app/templates/index.html @@ -0,0 +1,20 @@ + + + + {% if title %} + {{ title }} - Microblog + {% else %} + Welcome to Microblog + {% endif %} + + + +

Hi, {{ user.username }}!

+ {% for post in posts %} +
+

{{ post.author.username }} says: {{ post.body }}

+
+ {% endfor %} + + + \ No newline at end of file