From 927b4119ea776d5bffe2d81185574565bd820a33 Mon Sep 17 00:00:00 2001 From: tmeissner Date: Mon, 29 Oct 2018 00:03:58 +0100 Subject: [PATCH] Chapter 8: Authentication blueprint (8b) --- app/__init__.py | 3 +++ app/auth/__init__.py | 7 +++++++ app/auth/views.py | 7 +++++++ app/templates/auth/login.html | 9 +++++++++ migrations/versions/e7148b675688_.py | 28 ++++++++++++++++++++++++++++ 5 files changed, 54 insertions(+) create mode 100644 app/auth/__init__.py create mode 100644 app/auth/views.py create mode 100644 app/templates/auth/login.html create mode 100644 migrations/versions/e7148b675688_.py diff --git a/app/__init__.py b/app/__init__.py index 53f8e65..24218cb 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -25,4 +25,7 @@ def create_app(config_name): from .main import main as main_blueprint app.register_blueprint(main_blueprint) + from .auth import auth as auth_blueprint + app.register_blueprint(auth_blueprint, url_prefix='/auth') + return app diff --git a/app/auth/__init__.py b/app/auth/__init__.py new file mode 100644 index 0000000..adecbde --- /dev/null +++ b/app/auth/__init__.py @@ -0,0 +1,7 @@ +from flask import Blueprint + + +auth = Blueprint('auth', __name__) + + +from . import views diff --git a/app/auth/views.py b/app/auth/views.py new file mode 100644 index 0000000..50109e0 --- /dev/null +++ b/app/auth/views.py @@ -0,0 +1,7 @@ +from flask import render_template +from . import auth + + +@auth.route('/login') +def login(): + return render_template('auth/login.html') diff --git a/app/templates/auth/login.html b/app/templates/auth/login.html new file mode 100644 index 0000000..50a1351 --- /dev/null +++ b/app/templates/auth/login.html @@ -0,0 +1,9 @@ +{% extends "base.html" %} + +{% block title %}Flasky - Login{% endblock %} + +{% block page_content %} + +{% endblock %} diff --git a/migrations/versions/e7148b675688_.py b/migrations/versions/e7148b675688_.py new file mode 100644 index 0000000..1ca6e7d --- /dev/null +++ b/migrations/versions/e7148b675688_.py @@ -0,0 +1,28 @@ +"""empty message + +Revision ID: e7148b675688 +Revises: +Create Date: 2018-10-28 23:58:52.794660 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = 'e7148b675688' +down_revision = None +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.add_column('users', sa.Column('password_hash', sa.String(length=128), nullable=True)) + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.drop_column('users', 'password_hash') + # ### end Alembic commands ###