-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
274 changed files
with
182 additions
and
122 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
FLASK_APP = bulletin_board | ||
FLASK_ENV=development | ||
# FLASK_APP=app | ||
FLASK_APP = "app:create_app('development')" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -76,3 +76,5 @@ fabric.properties | |
|
||
# Android studio 3.1+ serialized cache file | ||
.idea/caches/build_file_checksums.ser | ||
|
||
*.env |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import os | ||
from flask import Flask, url_for, redirect | ||
from flask_login import LoginManager | ||
from flask_migrate import Migrate | ||
|
||
from config import config | ||
from app.department.models import db | ||
|
||
|
||
def create_app(config_name=None): | ||
app = Flask(__name__, static_url_path='') | ||
configure_app(app, config_name) # 导入参数设置 | ||
db.init_app(app) # 初始化绑定app对象 | ||
migrate = Migrate(app, db) | ||
login_manager = LoginManager(app) | ||
login_manager.login_view = 'login.login' | ||
login_manager.login_message = '访问页面需要登录' | ||
|
||
@login_manager.user_loader | ||
def load_user(user_id): | ||
# from .department.models import Department | ||
from app.department.models import Department | ||
dep = Department.query.get(int(user_id)) | ||
return dep | ||
|
||
# 引入蓝图并注册 | ||
from app import login, admin, user, department, commands | ||
app.register_blueprint(login.bp) # 注册登录页面视图 | ||
app.register_blueprint(admin.admin) # 注册管理员页面视图 | ||
app.register_blueprint(user.user) # 注册用户页面视图 | ||
app.register_blueprint(department.department) # 注册部门管理页面视图 | ||
app.register_blueprint(commands.bp) # 注册部门管理页面视图 | ||
|
||
# 注册首页路由 | ||
@app.route('/') | ||
def hello_world(): | ||
return redirect(url_for('login.login')) | ||
|
||
return app | ||
|
||
|
||
def configure_app(app, config_name=None): | ||
if config_name is None: | ||
config_name = os.environ.get('FLASK_ENV', 'development') | ||
if config_name in config: | ||
app.config.from_object(config[config_name]) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from flask import Blueprint | ||
|
||
admin = Blueprint('admin', __name__, url_prefix='/admin/') | ||
|
||
from .views import * |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
# flask-sqlalchemy的基本使用 | ||
from exts import db | ||
# db的引用关系: exts<-admin<-department | ||
from app.exts import db | ||
|
||
|
||
# 柱状图数据表 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from flask import Blueprint | ||
|
||
department = Blueprint('department', __name__, url_prefix='/') | ||
|
||
from .views import * |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from flask import Blueprint | ||
|
||
bp = Blueprint('login', __name__, url_prefix='/') | ||
|
||
from .views import * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from flask import Blueprint | ||
|
||
user = Blueprint('user', __name__, url_prefix='/user/') | ||
|
||
from .views import * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import os | ||
|
||
basedir = os.path.abspath(os.path.dirname(__file__)) | ||
HOST = os.environ.get('HOST') | ||
PORT = os.environ.get('PORT') | ||
USER = os.environ.get('USER') | ||
PASSWORD = os.environ.get('PASSWORD') | ||
CHARSET = os.environ.get('CHARSET') | ||
|
||
# 上传配置 | ||
UPLOAD_FOLDER = os.environ.get('UPLOAD_FOLDER') | ||
MAX_CONTENT_LENGTH = 128 * 1024 * 1024 # 128MB | ||
|
||
|
||
class BaseConfig: | ||
# SQLALCHEMY配置 | ||
SQLALCHEMY_TRACK_MODIFICATIONS = False | ||
SQLALCHEMY_ECHO = False | ||
|
||
|
||
class DevelopmentConfig(BaseConfig): | ||
SECRET_KEY = 'dev' | ||
DEBUG = True | ||
DATABASE = 'cyk_flask' | ||
DB_URI = 'mysql+pymysql://{}:{}@{}:{}/{}?{}'.format(USER, PASSWORD, HOST, PORT, DATABASE, CHARSET) | ||
SQLALCHEMY_DATABASE_URI = DB_URI | ||
|
||
|
||
class TestingConfig(BaseConfig): | ||
SECRET_KEY = 'test' | ||
DATABASE = 'cyk_flask_test' | ||
DB_URI = 'mysql+pymysql://{}:{}@{}:{}/{}?{}'.format(USER, PASSWORD, HOST, PORT, DATABASE, CHARSET) | ||
SQLALCHEMY_DATABASE_URI = DB_URI | ||
|
||
|
||
class ProductionConfig(BaseConfig): | ||
SECRET_KEY = os.environ.get('SECRET_KEY') | ||
DATABASE = 'cyk_flask' | ||
DB_URI = 'mysql+pymysql://{}:{}@{}:{}/{}?{}'.format(USER, PASSWORD, HOST, PORT, DATABASE, CHARSET) | ||
SQLALCHEMY_DATABASE_URI = DB_URI | ||
|
||
|
||
config = { | ||
'development': DevelopmentConfig, | ||
'testing': TestingConfig, | ||
'production': ProductionConfig, | ||
'default': DevelopmentConfig | ||
} | ||
|
Empty file.
Empty file.
Oops, something went wrong.