File tree Expand file tree Collapse file tree 3 files changed +35
-18
lines changed Expand file tree Collapse file tree 3 files changed +35
-18
lines changed Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ def __init__(self, env):
1717 app .config .from_object (env_config )
1818
1919 # Register the flask_app's routes and bind them to the app
20- from flask_app .routes import Routes
20+ from .routes import routes
2121 app .register_blueprint (routes .app )
2222
2323 return app
Original file line number Diff line number Diff line change 1- from flask import Blueprint , render_template
2-
3- class Routes :
4- app = Blueprint ('app' , __name__ )
5-
6- # Get the pages directory relative to the webrpot
7- pages_dir = os .path .join (app .instance_path , 'pages' )
8-
9- # All pages are dict values with their page name as the key,
10- # and the following path within the pages_dir: {page}/{page}.html
11- Pages = { page : os .path .join (pages_dir , '%s/%s.html' % page ) for page in [
12- 'Main'
13- ]}
14-
15- @app .route ('/' , methods = ['GET' , 'POST' ])
16- def index ():
17- return render_template (Pages .Main )
1+ import ../ routes / routes
Original file line number Diff line number Diff line change 1+ from flask import Blueprint , render_template
2+
3+ class Routes :
4+
5+ """
6+ A static list of available pages within the webapp
7+ """
8+ Pages = None
9+
10+ def __init__ (self , parent_app ) {
11+ """ Routes constructor """
12+
13+ """ The parent app instance this Routes instance belongs to """
14+ self .parent_app = app
15+
16+ """ The app blueprint for defining and handling routes """
17+ self .app_blueprint = Blueprint ('app' , __name__ )
18+
19+ """ The pages directory relative to the webroot """
20+ self .pages_dir = os .path .join (app .instance_path , 'pages' )
21+
22+ """
23+ All pages are dict values with their page name as the key,
24+ and the following path within the pages_dir: {page}/{page}.html
25+ """
26+ Pages = { page : os .path .join (pages_dir , '%s/%s.html' % page ) for page in [
27+ 'Main'
28+ ]} if Pages is None else Pages # Do not re-determine Pages if they've already been determined
29+ }
30+
31+ @app_blueprint .route ('/' , methods = ['GET' , 'POST' ])
32+ def index ():
33+ return render_template (Pages .Main )
You can’t perform that action at this time.
0 commit comments