service

作者: 月夜星空下 | 来源:发表于2022-04-14 09:35 被阅读0次
import json
import datetime
import logging
from tornado.web import Application, RequestHandler
from tornado.ioloop import IOLoop

# logging.basicConfig(
#     level=logging.INFO,
logging.basicConfig(filename='szse1.log', level=logging.INFO)
logging.debug('debug message')
logging.info('info message')
logging.error('error message')
logging.critical('critical message')

class compliance(RequestHandler):
    def post(self):
        get_time = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
        logging.info(f'<call time:{get_time}>')
        jsonbyte = self.request.body
        jsonstr = jsonbyte.decode('utf8')  # 解码,二进制转为字符串
        jsonobj = json.loads(jsonstr)  # 将字符串转为json对象
        result = json.dumps('', ensure_ascii=False)
        self.write(result)

def make_app():
    urls = [
        ("/v1/compliance=/", compliance),
    ]
    return Application(urls, debug=True)


if __name__ == '__main__':
    app = make_app()
    app.listen(10008)
    IOLoop.instance().start()

相关文章

网友评论

      本文标题:service

      本文链接:https://www.haomeiwen.com/subject/cgbasrtx.html