Skip to content

Commit

Permalink
Blueprints version 1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
lfernandez55 committed Feb 7, 2020
1 parent f834a9b commit fa63b9f
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 126 deletions.
22 changes: 1 addition & 21 deletions app/__init__.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,11 @@
# __init__.py is a special Python file that allows a directory to become
# a Python package so it can be accessed using the 'import' statement.

from datetime import datetime
import os

from flask import Flask
from flask_sqlalchemy import SQLAlchemy

# this is defined globally - so a little differently than how we used to do it
# see how it's connected to the flask app below
#db = SQLAlchemy()

# Initialize Flask Application
def create_app(extra_config_settings={}):
"""Create a Flask application.
"""

# Instantiate Flask
app = Flask(__name__)

Expand All @@ -23,21 +14,10 @@ def create_app(extra_config_settings={}):
# Load extra settings from extra_config_settings param
app.config.update(extra_config_settings)

# Setup Flask-SQLAlchemy
# up to now we did: db = SQLAlchemy(app) now we do:
#db.init_app(app)

# Register blueprints
from .views import register_blueprints
register_blueprints(app)

# Setup Flask-User to handle user account related forms
# from .models.user_models import User

# declare your app.context processors here
# @app.context_processor



return app

Expand Down
80 changes: 0 additions & 80 deletions app/models/user_models.py

This file was deleted.

2 changes: 1 addition & 1 deletion app/templates/books/foo.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<h1>In foo</h1>
<h1>In books/foo</h1>
1 change: 0 additions & 1 deletion app/templates/cars/baz.html

This file was deleted.

1 change: 1 addition & 0 deletions app/templates/main/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<h1>In main/index.html</h1>
4 changes: 2 additions & 2 deletions app/views/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
# a Python package so it can be accessed using the 'import' statement.

from .book_views import book_blueprint
from .car_views import car_blueprint
from .main_views import main_blueprint

def register_blueprints(app):
app.register_blueprint(book_blueprint)

def register_blueprints(app):
app.register_blueprint(car_blueprint)
app.register_blueprint(main_blueprint)
4 changes: 1 addition & 3 deletions app/views/book_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@


from flask import Blueprint, redirect, render_template
from flask import request, url_for


#from app import db

#after defining the book_blueprint you use it as a decorator in your views below
book_blueprint = Blueprint('books', __name__, template_folder='templates')


Expand Down
18 changes: 0 additions & 18 deletions app/views/car_views.py

This file was deleted.

15 changes: 15 additions & 0 deletions app/views/main_views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright 2014 SolidBuilds.com. All rights reserved
#
# Authors: Ling Thio <ling.thio@gmail.com>


from flask import Blueprint, render_template


#after defining the main_blueprint you use it as a decorator in your views below
main_blueprint = Blueprint('main', __name__, template_folder='templates')


@main_blueprint.route('/')
def baz():
return render_template('main/index.html')

0 comments on commit fa63b9f

Please sign in to comment.