Skip to content

Commit 9ad2d42

Browse files
committed
fleshed out the empty folder structure
1 parent b0a8044 commit 9ad2d42

File tree

9 files changed

+67
-0
lines changed

9 files changed

+67
-0
lines changed

app/__init__.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
from flask import Flask
2+
from config import config
3+
4+
def create_app(config_name):
5+
app = Flask(__name__)
6+
app.config.from_object(config[config_name])
7+
config[config_name].init_app(app)
8+
9+
from .main import main as main_blueprint
10+
app.register_blueprint(main_blueprint)
11+
12+
return app

app/main/__init__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from flask import Blueprint
2+
3+
main = Blueprint('main', __name__)
4+
5+
from . import views, errors

app/main/errors.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
from flask import render_template
2+
from . import main
3+
4+
@main.app_errorhandler(404)
5+
def page_not_found(e):
6+
return render_template('404.html'), 404
7+
8+
@main.app_errorhandler(500)
9+
def internal_server_error(e):
10+
return render_template('500.html'), 500

app/main/views.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
from flask import render_template
2+
from . import main
3+
4+
5+
@main.route('/', methods=['GET'])
6+
def index():
7+
return render_template('index.html')

app/templates/404.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
404

app/templates/500.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
500

app/templates/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
index

config.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import os
2+
basedir = os.path.abspath(os.path.dirname(__file__))
3+
4+
class Config:
5+
SECRET_KEY = os.environ.get('SECRET_KEY') or 'hard to guess string'
6+
7+
@staticmethod
8+
def init_app(app):
9+
pass
10+
11+
class DevelopmentConfig(Config):
12+
DEBUG = True
13+
14+
class TestingConfig(Config):
15+
TESTING = True
16+
17+
class ProductionConfig(Config):
18+
pass
19+
20+
config = {
21+
'development': DevelopmentConfig,
22+
'testing': TestingConfig,
23+
'production': ProductionConfig,
24+
'default': DevelopmentConfig
25+
}

flasky.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import os
2+
from app import create_app
3+
4+
5+
app = create_app(os.getenv('FLASK_CONFIG') or 'default')

0 commit comments

Comments
 (0)