flask pages
This commit is contained in:
39
flaskpages/__init__.py
Normal file
39
flaskpages/__init__.py
Normal file
@@ -0,0 +1,39 @@
|
||||
import os
|
||||
|
||||
from flask import Flask
|
||||
from flaskpages import pages
|
||||
import logging
|
||||
def create_app(test_config=None):
|
||||
"""Create and configure an instance of the Flask application."""
|
||||
app = Flask(__name__, instance_relative_config=True)
|
||||
app.config.from_mapping(
|
||||
# a default secret that should be overridden by instance config
|
||||
SECRET_KEY="dev",
|
||||
URL_PREFIX = "/"
|
||||
)
|
||||
|
||||
if not test_config:
|
||||
# load the instance config, if it exists, when not testing
|
||||
app.config.from_pyfile("cfg.py")
|
||||
else:
|
||||
# load the test config if passed in
|
||||
app.config.update(test_config)
|
||||
|
||||
# ensure the instance folder exists
|
||||
try:
|
||||
os.makedirs(app.instance_path)
|
||||
except OSError:
|
||||
pass
|
||||
if app.config["DEBUG"]:
|
||||
app.logger.setLevel(logging.DEBUG)
|
||||
@app.route("/hello")
|
||||
def hello():
|
||||
return "Hello, World!"
|
||||
|
||||
app.logger.debug(app.config)
|
||||
app.register_blueprint(pages.create_bp(app), url_prefix = app.config["URL_PREFIX"], static_folder='static')
|
||||
|
||||
|
||||
app.add_url_rule("/", endpoint="index")
|
||||
|
||||
return app
|
||||
Reference in New Issue
Block a user