server:
当调用http://xxx.xxx.xxx.xxx:4500/push时就会触发get_push函数
from bottle import run, route, request import logging import time import os filename = str(os.path.basename(__file__).split('.')[0]) + ".log" logger = logging.getLogger() logger.setLevel(logging.INFO) push_log = logging.FileHandler(filename, 'a', encoding='utf-8') push_log.setLevel(logging.INFO) # formatter = logging.Formatter("%(asctime)s - %(levelname)s - %(message)s") # push_log.setFormatter(formatter) logger.addHandler(push_log) @route('/push', method=['GET', 'POST']) def get_push(): logging.info("---------接收数据时间" + str(time.strftime('%Y-%m-%d %H:%M:%S', time.localtime())) + "---------") body = request.body.decode() logging.info(body) return "200" if __name__ == '__main__': run(host="xxx.xxx.xxx.xxx", port=4500, debug=True)
标签:__,web,logging,log,python,xxx,bottle,push,import From: https://www.cnblogs.com/mian-1122/p/17106826.html