30 lines
650 B
Python
30 lines
650 B
Python
import os
|
|
|
|
from flask import Flask
|
|
|
|
|
|
def create_app(test_config=None):
|
|
"""Create and configure the app."""
|
|
app = Flask(__name__, instance_relative_config=True)
|
|
|
|
if test_config is None:
|
|
# Load the instance config, if it exists, when not testing.
|
|
app.config.from_pyfile("config.py", silent=True)
|
|
else:
|
|
# Load the test config if passed in.
|
|
app.config.from_mapping(test_config)
|
|
|
|
# Ensure the instance folder exists.
|
|
try:
|
|
os.makedirs(app.instance_path)
|
|
except OSError:
|
|
pass
|
|
|
|
@app.route("/")
|
|
def index():
|
|
return "hello, world!"
|
|
|
|
return app
|
|
|
|
app = create_app()
|