Example #1
0
def save_photo():
    if request.method == "POST":
        img = request.files.get("image")
        log.info(dir(img))
        img.save("./static/photo/" + img.filename)
        return jsonify({"msg": "succ"})
    elif request.method == "GET":
        return jsonify({"msg": "list"})
Example #2
0
def server():
    handler = RedeemCodeHandler()
    processor = RedeemCode.Processor(handler)
    transport = TSocket.TServerSocket(host=config.HOST, port=config.PORT)
    tfactory = TTransport.TBufferedTransportFactory()
    pfactory = TBinaryProtocol.TBinaryProtocolFactory()
    thrift_server = TServer.TThreadPoolServer(processor, transport, tfactory, pfactory)
    thrift_server.setNumThreads(config.threads)

    start_log()

    try:
        thrift_server.serve()
    except KeyboardInterrupt:
        log.info('server done.')
        os.kill(os.getpid(), signal.SIGTERM)
        sys.exit(0)

    log.info('server done.')
Example #3
0
def start_log():
    '''服务启动日志'''
    log.info('Starting the server...')
    log.info('host:%s', config.HOST)
    log.info('port:%d', config.PORT)
    log.info('thread_num:%d', config.threads)