├── app ├── templates │ ├── 404.html │ └── index.html ├── core │ ├── __init__.py │ └── views.py └── __init__.py ├── README.md ├── requirements.txt ├── run.py ├── config.py └── .gitignore /app/templates/404.html: -------------------------------------------------------------------------------- 1 | not found 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # flask-demo 2 | flask-demo 3 | -------------------------------------------------------------------------------- /app/core/__init__.py: -------------------------------------------------------------------------------- 1 | __author__ = 'z' 2 | -------------------------------------------------------------------------------- /app/templates/index.html: -------------------------------------------------------------------------------- 1 | this is a demo 2 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | Flask==0.10.1 2 | Flask-Login==0.2.11 3 | itsdangerous==0.24 4 | Jinja2==2.7.3 5 | MarkupSafe==0.23 6 | Werkzeug==0.10.4 7 | wheel==0.24.0 8 | -------------------------------------------------------------------------------- /run.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python2 2 | # -*- coding: UTF-8 -*- 3 | 4 | import os 5 | from app import create_app 6 | 7 | app = create_app(os.getenv('FLASK_CONFIG') or 'default') 8 | 9 | if __name__ == '__main__': 10 | app.run() 11 | -------------------------------------------------------------------------------- /app/core/views.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python2 2 | # -*- coding: UTF-8 -*- 3 | 4 | from flask import Blueprint, render_template 5 | 6 | mod = Blueprint('core', __name__) 7 | 8 | 9 | @mod.app_errorhandler(404) 10 | def page_not_found(error): 11 | return render_template('404.html'), 404 12 | 13 | @mod.route('/') 14 | def index(): 15 | return render_template('index.html') 16 | -------------------------------------------------------------------------------- /app/__init__.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python2 2 | # -*- coding: UTF-8 -*- 3 | 4 | from flask import Flask 5 | from flask.ext.login import LoginManager 6 | 7 | from config import config 8 | 9 | login_manager = LoginManager() 10 | 11 | def create_app(config_name): 12 | app = Flask(__name__) 13 | app.config.from_object(config[config_name]) 14 | 15 | from app.core.views import mod as core_blueprint 16 | app.register_blueprint(core_blueprint, url_prefix='/') 17 | 18 | login_manager.init_app(app) 19 | 20 | 21 | return app 22 | 23 | 24 | -------------------------------------------------------------------------------- /config.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python2 2 | # -*- coding: UTF-8 -*- 3 | 4 | class Config(object): 5 | DEBUG = False 6 | TESTING = False 7 | SECRET_KEY = '?\xbf,\xb4\x8d\xa3"<\x9c\xb0@\x0f5\xab,w\xee\x8d$0\x13\x8b83' 8 | 9 | @staticmethod 10 | def init_app(): 11 | pass 12 | 13 | class ProductionConfig(Config): 14 | pass 15 | 16 | class DevelopmentConfig(Config): 17 | DEBUG = True 18 | 19 | config = { 20 | 'development': DevelopmentConfig, 21 | 'Production': ProductionConfig, 22 | 'default': DevelopmentConfig 23 | } 24 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | 5 | # C extensions 6 | *.so 7 | 8 | # Distribution / packaging 9 | .Python 10 | env/ 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | *.egg-info/ 23 | .installed.cfg 24 | *.egg 25 | 26 | # PyInstaller 27 | # Usually these files are written by a python script from a template 28 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 29 | *.manifest 30 | *.spec 31 | 32 | # Installer logs 33 | pip-log.txt 34 | pip-delete-this-directory.txt 35 | 36 | # Unit test / coverage reports 37 | htmlcov/ 38 | .tox/ 39 | .coverage 40 | .coverage.* 41 | .cache 42 | nosetests.xml 43 | coverage.xml 44 | *,cover 45 | 46 | # Translations 47 | *.mo 48 | *.pot 49 | 50 | # Django stuff: 51 | *.log 52 | 53 | # Sphinx documentation 54 | docs/_build/ 55 | 56 | # PyBuilder 57 | target/ 58 | --------------------------------------------------------------------------------