-
Notifications
You must be signed in to change notification settings - Fork 43
/
Copy pathapplication.py
32 lines (26 loc) · 1.09 KB
/
application.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# -*- coding: utf-8 -*-
from flask import Flask
from flask_script import Manager
from flask_sqlalchemy import SQLAlchemy
import os
from flask_cors import CORS
from datetime import timedelta
class Application(Flask):
def __init__(self, import_name, template_folder=None, root_path=None):
super(Application, self).__init__(import_name, template_folder=template_folder, root_path=root_path,
static_folder=None)
self.config.from_pyfile('config/config.default.py')
db.init_app(self)
db = SQLAlchemy()
app = Application(__name__, template_folder=os.getcwd() + "/app/templates/", root_path=os.getcwd())
manager = Manager(app)
CORS(app, supports_credentials=True)
app.secret_key = app.config['SESSION_KEY']
app.config['PERMANENT_SESSION_LIFETIME'] = timedelta(app.config['SESSION_TIME'])
'''
函数模板
'''
from app.helper.UrlManager import UrlManager
app.add_template_global(UrlManager.buildStaticUrl, 'buildStaticUrl')
app.add_template_global(UrlManager.buildUrl, 'buildUrl')
app.add_template_global(UrlManager.buildImageUrl, 'buildImageUrl')