diff --git a/__pycache__/config.cpython-38.pyc b/__pycache__/config.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..0c35bf379c8bcdc7751d23a7d08c1110a596a303 Binary files /dev/null and b/__pycache__/config.cpython-38.pyc differ diff --git a/app.py b/app.py deleted file mode 100644 index 87b4b21b91196f2c24483cfba656312c101e7a65..0000000000000000000000000000000000000000 --- a/app.py +++ /dev/null @@ -1,7 +0,0 @@ -from flask import Flask - -app = Flask(__name__) - -@app.route("/") -def hello_world(): - return "<p>Hello, World!</p>" \ No newline at end of file diff --git a/app/__init__.py b/app/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..50c8aaeb99ccd60f77a04eb5cd1d7b01447cfc25 --- /dev/null +++ b/app/__init__.py @@ -0,0 +1,24 @@ +# Boilerplate code taken from https://www.digitalocean.com/community/tutorials/how-to-structure-a-large-flask-application-with-flask-blueprints-and-flask-sqlalchemy + +from flask import Flask + +from config import Config + +def create_app(config_class=Config): + app = Flask(__name__) + app.config.from_object(config_class) + + # Initialize Flask extensions here + + # Register blueprints here + from app.main import bp as main_bp + app.register_blueprint(main_bp) + + from app.posts import bp as posts_bp + app.register_blueprint(posts_bp, url_prefix='/posts') + + @app.route('/test/') + def test_page(): + return '<h1>Testing the Flask Application Factory Pattern</h1>' + + return app \ No newline at end of file diff --git a/app/__pycache__/__init__.cpython-38.pyc b/app/__pycache__/__init__.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..0ee55363136ae5fd881a76cf1026f4326fee8c09 Binary files /dev/null and b/app/__pycache__/__init__.cpython-38.pyc differ diff --git a/app/main/__init__.py b/app/main/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..f1c69e275022874f5afa0d7339878192a32b387f --- /dev/null +++ b/app/main/__init__.py @@ -0,0 +1,5 @@ +from flask import Blueprint + +bp = Blueprint('main', __name__) + +from app.main import routes \ No newline at end of file diff --git a/app/main/__pycache__/__init__.cpython-38.pyc b/app/main/__pycache__/__init__.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..2e52d4ba6b0cc785344894599fab45b46702aad7 Binary files /dev/null and b/app/main/__pycache__/__init__.cpython-38.pyc differ diff --git a/app/main/__pycache__/routes.cpython-38.pyc b/app/main/__pycache__/routes.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..a8a49a225f7c9581974ad5ae76d43a0cd13d061b Binary files /dev/null and b/app/main/__pycache__/routes.cpython-38.pyc differ diff --git a/app/main/routes.py b/app/main/routes.py new file mode 100644 index 0000000000000000000000000000000000000000..81fa7a7ededa9c3dbe88a6b5863e0f903afe74ad --- /dev/null +++ b/app/main/routes.py @@ -0,0 +1,6 @@ +from flask import render_template +from app.main import bp + +@bp.route('/') +def index(): + return render_template('index.html') \ No newline at end of file diff --git a/app/posts/__init__.py b/app/posts/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..1b2c0d783cf76afe155c4ab76c01a2ea92413d9f --- /dev/null +++ b/app/posts/__init__.py @@ -0,0 +1,5 @@ +from flask import Blueprint + +bp = Blueprint('posts', __name__) + +from app.posts import routes \ No newline at end of file diff --git a/app/posts/__pycache__/__init__.cpython-38.pyc b/app/posts/__pycache__/__init__.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..515ccdf6896ca63e8f65686047a57f4eeaf91c77 Binary files /dev/null and b/app/posts/__pycache__/__init__.cpython-38.pyc differ diff --git a/app/posts/__pycache__/routes.cpython-38.pyc b/app/posts/__pycache__/routes.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..b418aec72a8ba5ddade836c9160f461f37f2efbe Binary files /dev/null and b/app/posts/__pycache__/routes.cpython-38.pyc differ diff --git a/app/posts/routes.py b/app/posts/routes.py new file mode 100644 index 0000000000000000000000000000000000000000..95e1be7c9b239d96d24a801b0eea9eae25ac0fdc --- /dev/null +++ b/app/posts/routes.py @@ -0,0 +1,6 @@ +from flask import render_template +from app.posts import bp + +@bp.route('/') +def index(): + return render_template('posts/index.html') diff --git a/app/templates/base.html b/app/templates/base.html new file mode 100644 index 0000000000000000000000000000000000000000..013b57adf93d05e25b3796ff340eac7595b55543 --- /dev/null +++ b/app/templates/base.html @@ -0,0 +1,10 @@ +<body> +<nav> + <a href="{{ url_for('main.index') }}">HOME</a> + <a href="#">Posts</a> +</nav> +<hr> +<div class="content"> + {% block content %} {% endblock %} +</div> +</body> \ No newline at end of file diff --git a/app/templates/index.html b/app/templates/index.html new file mode 100644 index 0000000000000000000000000000000000000000..c5a42d6bbd98eed4cfc652080146b20004515314 --- /dev/null +++ b/app/templates/index.html @@ -0,0 +1,7 @@ +{% extends 'base.html' %} + +{% block content %} + <div class="content"> + <h2>Index.html</h2> + </div> +{% endblock %} \ No newline at end of file diff --git a/app/templates/posts/index.html b/app/templates/posts/index.html new file mode 100644 index 0000000000000000000000000000000000000000..ad42a406597c85a31840762f26271d5eaa35ae49 --- /dev/null +++ b/app/templates/posts/index.html @@ -0,0 +1,7 @@ +{% extends 'base.html' %} + +{% block content %} + <div class="content"> + <h2>Index of posts.html</h2> + </div> +{% endblock %} \ No newline at end of file diff --git a/config.py b/config.py new file mode 100644 index 0000000000000000000000000000000000000000..ec3b9f6c7fccc3be004eccedfd44d27b428af6fc --- /dev/null +++ b/config.py @@ -0,0 +1,10 @@ +import os + +basedir = os.path.abspath(os.path.dirname(__file__)) + + +class Config: + SECRET_KEY = os.environ.get('SECRET_KEY') + SQLALCHEMY_DATABASE_URI = os.environ.get('DATABASE_URI')\ + or 'sqlite:///' + os.path.join(basedir, 'app.db') + SQLALCHEMY_TRACK_MODIFICATIONS = False \ No newline at end of file diff --git a/static/core.css b/static/core.css new file mode 100644 index 0000000000000000000000000000000000000000..e89b7b71378f523d0b1711307641e6a148d52e3c --- /dev/null +++ b/static/core.css @@ -0,0 +1 @@ +/* Core CSS Style types */ \ No newline at end of file