diff --git a/.flaskenv b/.flaskenv new file mode 100644 index 0000000000000000000000000000000000000000..f0b0159d24d47836b6ab6a48bc5f0e6e36031ed0 --- /dev/null +++ b/.flaskenv @@ -0,0 +1,4 @@ +FLASK_APP=app +FLASK_ENV=development +FLASK_DEBUG=1 +TEMPLATES_AUTO_RELOAD=1 diff --git a/app/.env b/app/.env new file mode 100644 index 0000000000000000000000000000000000000000..1cef5b283a56affa40248dcf853cdeaef5904a9d --- /dev/null +++ b/app/.env @@ -0,0 +1,3 @@ +SQLALCHEMY_DATABASE_URI = "sqlite:///../database.db" +SECRET_KEY = "99b96cccf0a26d2f07b5e0ee" +FLASK_ENV = "development" diff --git a/app/__init__.py b/app/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..705db8e50a08df5492ed369a0a4d2269f46748ed --- /dev/null +++ b/app/__init__.py @@ -0,0 +1,33 @@ +# Flask init for the web app. +from flask import Flask +from database import db +from dotenv import load_dotenv +import os + +# Jago Gardiner (21009267) +class Config(object): + TEMPLATES_AUTO_RELOAD = True + DEBUG = True + + # Flask settings + load_dotenv() + SECRET_KEY = os.getenv("SECRET_KEY") + SQLALCHEMY_DATABASE_URI = os.getenv("SQLALCHEMY_DATABASE_URI") + + # Flask-SQLAlchemy settings + SQLALCHEMY_TRACK_MODIFICATIONS = False # Avoids SQLAlchemy warning + + +def create_app(): + app = Flask(__name__) + app.config.from_object(Config) + + # Initialize the database + db.init_app(app) + + # Register the blueprints + from .main import app as app_blueprint + + app.register_blueprint(app_blueprint) + + return app diff --git a/app/__pycache__/__init__.cpython-310.pyc b/app/__pycache__/__init__.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..3e06915854680f3cf902a9887d1ae0b233663c70 Binary files /dev/null and b/app/__pycache__/__init__.cpython-310.pyc differ diff --git a/app/__pycache__/main.cpython-310.pyc b/app/__pycache__/main.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..378f9ca1a8fe4ab8923070b3e0715d6eb986fe6d Binary files /dev/null and b/app/__pycache__/main.cpython-310.pyc differ diff --git a/app/__pycache__/routes.cpython-310.pyc b/app/__pycache__/routes.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..cd20acad447a9bb3022519b880949c92c69ba610 Binary files /dev/null and b/app/__pycache__/routes.cpython-310.pyc differ diff --git a/app/main.py b/app/main.py new file mode 100644 index 0000000000000000000000000000000000000000..5f8a51648b2212090787be977366eb6e24d4d62f --- /dev/null +++ b/app/main.py @@ -0,0 +1,11 @@ +# Flask main file +# Path: app/main.py + +# Jago Gardiner (21009267) +from flask import Blueprint + +app = Blueprint("app", __name__) + +# Import the routes +# Avoid circular imports +from app import routes diff --git a/app/routes.py b/app/routes.py new file mode 100644 index 0000000000000000000000000000000000000000..53bce8b7cd2de6a782b932daa42973c9cddabc1b --- /dev/null +++ b/app/routes.py @@ -0,0 +1,9 @@ +# Flask website routing +from flask import render_template +from .main import app + + +@app.route("/") +@app.route("/index") +def home(): + return render_template("index.html") diff --git a/app/templates/index.html b/app/templates/index.html new file mode 100644 index 0000000000000000000000000000000000000000..4edcbfd07f09aa8b56e6b6b0ed511a80dfea1a1a --- /dev/null +++ b/app/templates/index.html @@ -0,0 +1,9 @@ +<!-- quick landing page --> +<div class="container"> + <div class="row"> + <div class="col-md-12"> + <h1>Example</h1> + <p class="lead">hello</p> + </div> + </div> +</div> diff --git a/database.db b/database.db new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/database/__init__.py b/database/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..29c1f07c78e3a49b392362814072c83af922f8b3 --- /dev/null +++ b/database/__init__.py @@ -0,0 +1,5 @@ +# db module init +from flask_sqlalchemy import SQLAlchemy + +# db module init +db = SQLAlchemy() diff --git a/database/__pycache__/__init__.cpython-310.pyc b/database/__pycache__/__init__.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..ce1b29131bc4192fc5d36a32baf1e3e3b032eb0c Binary files /dev/null and b/database/__pycache__/__init__.cpython-310.pyc differ