Skip to content

Commit ad68eed

Browse files
committed
Re-organize file structure
1 parent a6a90cf commit ad68eed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+83
-54
lines changed

README.md

Lines changed: 6 additions & 6 deletions

app/app.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Python Standard Library
2+
import os
3+
4+
# Third-Party Libraries
5+
from flask import Flask
6+
from flask_session import Session
7+
8+
# Local Libraries
9+
from blueprints.main.routes import main_bp
10+
# from blueprints.cms.routes import cms_bp # Uncomment this line to enable CMS
11+
12+
13+
14+
15+
16+
# Configure application
17+
app = Flask(__name__)
18+
19+
# Set secret key for session management
20+
app.config['SECRET_KEY'] = os.getenv('SECRET_KEY')
21+
22+
# Disable file caching and enable template auto-reloading
23+
app.config['SEND_FILE_MAX_AGE_DEFAULT'] = 0
24+
app.config['TEMPLATES_AUTO_RELOAD'] = True
25+
26+
# Configure session to use filesystem (instead of signed cookies)
27+
app.config["SESSION_PERMANENT"] = False
28+
app.config["SESSION_TYPE"] = "filesystem"
29+
30+
# Initialize session with the app
31+
Session(app)
32+
33+
# Register blueprints for main and cms routes
34+
app.register_blueprint(main_bp)
35+
# app.register_blueprint(cms_bp) # Uncomment this line to enable CMS

app/blueprints/main/__init__.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Third-Party Libraries
2+
from flask import Blueprint
3+
4+
5+
6+
7+
8+
main_bp = Blueprint('main_bp',
9+
__name__,
10+
static_folder='static',
11+
static_url_path='/main/static',
12+
template_folder='templates')
13+
14+
from . import routes

app.py renamed to app/blueprints/main/routes.py

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,35 +2,26 @@
22
import os
33

44
# Third-Party Libraries
5-
from flask import Flask, redirect, render_template, request, session
6-
from flask_session import Session
5+
from flask import Blueprint
6+
from flask import redirect
7+
from flask import render_template
8+
from flask import request
9+
from flask import session
710

8-
# Local Libraries
11+
# Local
912
from helpers import get_series_data
1013
import queries
14+
from . import main_bp
1115

1216

1317

1418

15-
# Configure application
16-
app = Flask(__name__)
17-
app.config['SECRET_KEY'] = os.getenv('SECRET_KEY')
18-
19-
app.config['SEND_FILE_MAX_AGE_DEFAULT'] = 0
20-
app.config['TEMPLATES_AUTO_RELOAD'] = True
21-
22-
# Configure session to use filesystem (instead of signed cookies)
23-
app.config["SESSION_PERMANENT"] = False
24-
app.config["SESSION_TYPE"] = "filesystem"
25-
26-
Session(app)
27-
2819
# Set constants
2920
MAP_API_KEY = os.environ.get("MAP_API_KEY")
3021
DATABASE_NAME = os.environ.get("DATABASE_NAME")
3122

3223

33-
@app.route("/", methods=["GET", "POST"])
24+
@main_bp.route("/", methods=["GET", "POST"])
3425
def index():
3526
"""
3627
Handle the index route for the application.
@@ -72,7 +63,7 @@ def index():
7263
series_ids=series_ids)
7364

7465

75-
@app.route("/series", methods=["GET", "POST"])
66+
@main_bp.route("/series", methods=["GET", "POST"])
7667
def series_view():
7768
"""
7869
Handle the series view route for the application.
@@ -114,7 +105,7 @@ def series_view():
114105
return redirect("/")
115106

116107

117-
@app.route("/film", methods=["GET", "POST"])
108+
@main_bp.route("/film", methods=["GET", "POST"])
118109
def film_view():
119110
"""
120111
Handle the series view route for the application.
@@ -155,7 +146,7 @@ def film_view():
155146
return redirect("/")
156147

157148

158-
@app.route("/location")
149+
@main_bp.route("/location")
159150
def location_view():
160151
"""
161152
Handle the location view route for the application.
@@ -180,7 +171,7 @@ def location_view():
180171
map_api_key=MAP_API_KEY)
181172

182173

183-
@app.route("/org")
174+
@main_bp.route("/org")
184175
def org_view():
185176
"""
186177
Handle the org view route for the application.
File renamed without changes.
904 KB

0 commit comments

Comments
 (0)