Exemple #1
0
def export(tablename, resultDict, title):

    # 重置游标的位置
    # 搜取所有结果
    # 获取MYSQL里面的数据字段名称
    workbook = xlwt.Workbook(encoding='utf8')
    sheet = workbook.add_sheet('table', cell_overwrite_ok=True)

    # 写上字段信息
    for field in range(0, len(title)):
        sheet.write(0, field, title[field])

    # 获取并写入数据段信息

    for row in range(1, len(resultDict) + 1):
        for col in range(0, len(title)):
            sheet.write(row, col, u'%s' % resultDict[row - 1][col])

    # path2= os.getcwd()
    ExcelFile = tablename + '_' + str(random.randint(100000, 999999)) + '.xls'

    workbook.save("web/static/excel/" + ExcelFile)

    ip = get_ip()

    path = ip + ":" + ConfigUtils.getWebPorperties(KEYMAP.PORT)

    return 'http://' + path + '/static/excel/' + ExcelFile
Exemple #2
0
def parseResponse(errorCode,dict=None,flag=False):
    result=stringify(parseResponseJson(errorCode,dict))
    if flag:
        return result
    rsp = make_response(result)
    allowCrossOrigin=eval(ConfigUtils.getWebPorperties("ALLOW_CROSS_ORIGIN"))
    if allowCrossOrigin:
        rsp.headers['Access-Control-Allow-Origin'] = '*'
    rsp.mimetype = 'application/json;charset=utf-8'
    return rsp
Exemple #3
0
#coding=utf-8
#Created by xutao on 2017-04-14.
import logging

from Settings import LoggerLevel
from utils import ConfigUtils
from utils.ConfigUtils import KEYMAP
from web import start
from utils.LogUtils import LoggingFormatter, LoggingHandle
if __name__ == "__main__":
    # logging.basicConfig(level=LoggerLevel,
    #                     format='%(asctime)s %(filename)s[line:%(lineno)d] %(levelname)s %(message)s')
    formater = LoggingFormatter(filename='startFlask')
    handle = LoggingHandle()
    handle.setLevel(LoggerLevel)
    handle.setFormatter(formater)
    logging.getLogger('').addHandler(handle)
    start(host=ConfigUtils.getWebPorperties(KEYMAP.HOST),
          port=int(ConfigUtils.getWebPorperties(KEYMAP.PORT)))
Exemple #4
0
def start():
    app.run(host=ConfigUtils.getWebPorperties("CONFIG_HOST"),
            port=5002,
            threaded=True)