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"})
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.')
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)