# -*- coding: utf-8 -*- """ 程序入口 """ import config import time, math from utils.func import init_logger init_logger(None) from flask import Flask, Markup, render_template, request app = Flask(__name__) app.config.from_object(config) @app.context_processor def pjax_processor(): def get_template(base, pjax=None): pjax = pjax or 'pjax.html' if 'X-PJAX' in request.headers: return pjax else: return base return dict(pjax=get_template) @app.context_processor def pagination_processor(): def pagination(url, pager, template=None, params={}): template = template or 'mod/pagination.html'
from config import APP_MODE from config import MYSQL import redis import config app = Flask(__name__) app.config.from_object(config) FS.HOST = config.FS_HOST FS.PORT = config.FS_PORT LOGGER = init_logger(__name__) init_logger(None) rds = redis.StrictRedis(host=config.REDIS_HOST, port=config.REDIS_PORT, db=config.REDIS_DB, password=config.REDIS_PASSWORD) def http_error_handler(err): LOGGER.error(err) return render_template('error.html', description=str(err)) def response_meta_handler(response_meta):
from models import Account from models import Group from models import Store from models import Seller from core import RoleType, MainException, EmailUsageType, ResponseMeta from blueprint_utils import login_required from blueprint_utils import require_basic_auth from utils.func import init_logger from utils.func import random_ascii_string from config import APP_MODE from config import KEFU_APPID LOGGER = init_logger(__name__) api = Blueprint('api', __name__, url_prefix='/api') MODE_FIX = 1 MODE_ONLINE = 2 MODE_BROADCAST = 3 default_mode = MODE_FIX ##################user###################### @api.route('/login', methods=['POST']) def login_post(): """ """ account_obj = _get_account_by_email(g._db, request.form.get('email', ''))