Esempio n. 1
0
 def create_app(self):
     app = Flask(__name__)
     app.config['TESTING'] = True
     app.config['SERVER_NAME'] = 'localhost'
     app.config['SECRET_KEY'] = 'secret secret'
     app.config['IMAGES_PATH'] = ['assets']
     self.images = Images(app)
     return app
Esempio n. 2
0
from flask_bootstrap import Bootstrap
from flask_images import Images
from flask_cache import Cache
from flask_babel import Babel, _, lazy_gettext as _l
from flask_mail import Mail
from config import Config
from flask_login import LoginManager
from flask_uploads import UploadSet, IMAGES

VIDEOS = ('mp4', 'flv', 'mkv', 'avi')

db = SQLAlchemy()
migrate = Migrate()
bootstrap = Bootstrap()
cache = Cache()
babel = Babel()
images = Images()
login = LoginManager()
mail = Mail()
photos = UploadSet('photos', IMAGES)
sphotos = UploadSet('posts', IMAGES)
videos = UploadSet('videos', VIDEOS)
desc = sqlalchemy.desc
INSTITUTIONS = [
    "信息工程学院", "新闻与传媒学院", "广陵学院", " 文学院", "社会发展学院", "物理科学与技术学院", "化学化工学院",
    "教育科学学院(师范学院)", "学前教育学院", "数学科学学院", " 马克思主义学院", "农学院", "园艺与植物保护学院", "音乐学院",
    "美术与设计学院", "兽医学院", "动物科学与技术学院", "生物科学与技术学院", " 医学院", "护理学院", " 旅游烹饪学院",
    "水利与能源动力工程学院", "环境科学与工程学院", "机械工程学院", "法学院", "商学院", "外国语学院", "建筑科学与工程学院",
    "体育学院", " 广陵学院", "创新创业学院"
]
Esempio n. 3
0
@app.before_request
def log_request():
    if app.config.get('LOGGING_ON'):
        request_str = str(request)
        request_headers = str(request.headers)
        log_str = 'Request: ({0}); Headers: ({1})'.format(
            request_str, request_headers)
        app.logger.info(log_str)


if app.config.get('LOGGING_ON'):
    app_log_handlers = _create_log_handlers(app.config.get('GRAYLOG_CONFIG'))
    for app_log_handler in app_log_handlers:
        app.logger.addHandler(app_log_handler)
images = Images(app)
mail = Mail(app)
app.view_functions['images'] = images.handle_request
app.jinja_env.filters['display_pub_info'] = display_publication_info
app.jinja_env.filters['date_format'] = date_format
app.jinja_env.filters['w3c_date'] = w3c_date
app.jinja_env.globals.update(wsgi_str=app.config['WSGI_STR'])
app.jinja_env.globals.update(
    GOOGLE_ANALYTICS_CODE=app.config['GOOGLE_ANALYTICS_CODE'])
app.jinja_env.globals.update(
    GOOGLE_WEBMASTER_TOOLS_CODE=app.config['GOOGLE_WEBMASTER_TOOLS_CODE'])
app.jinja_env.globals.update(LAST_MODIFIED=app.config.get('DEPLOYED'))
app.jinja_env.globals.update(
    ANNOUNCEMENT_BLOCK=app.config['ANNOUNCEMENT_BLOCK'])

#Enable authentication
Esempio n. 4
0
from flask_bootstrap import Bootstrap
from flask_assets import Environment, Bundle
from flask_migrate import Migrate
from flask_images import Images
from flask_login import LoginManager, current_user
from flask_ckeditor import CKEditor
from flask_wtf.csrf import CSRFProtect
import flaskfilemanager, base64

mail = Mail()
moment = Moment()
db = SQLAlchemy()
bootstrap = Bootstrap()
assets = Environment()
migrate = Migrate()
image = Images()
ckeditor = CKEditor()
csrf = CSRFProtect()
login_manager = LoginManager()
login_manager.login_view = 'auth.login'


def create_app(config_name):
    app = Flask(__name__)
    app.config.from_object(config[config_name])
    config[config_name].init_app(app)
    # if app.config['SERVER_NAME']:
    #     app.add_url_rule('/<path:filename>', endpoint='static', view_func=app.send_static_file, subdomain='img')

    # with app.app_context():
    #     #Define access control for flaskfilemanager.
Esempio n. 5
0
application = Flask(__name__)
application.config.from_object(Config)

# Подключение (обслуживание) SSL
sslify = SSLify(application)

# CORS
CORS(application)

# SQLAlchemy + Migrate
db_lib = SQLA(application)
migrate = Migrate(application, db_lib)

# Login
login_manager = LoginManager(application)
login_manager.login_view = 'login'

# CSRF
csrf = CSRFProtect(application)

# Flask image
images = Images(application)

from app import views  # noqa
from app import viewsfuture  # noqa
from app import admin  # noqa
from .api import ver_one  # noqa

if __name__ == "__main__":
    application.run(host='0.0.0.0', port=5000)