itchatmp icon indicating copy to clipboard operation
itchatmp copied to clipboard

自定义路由改进

Open dlyili opened this issue 7 years ago • 1 comments

我修改了 \itchatmp\components\register.py 文件中的run函数,添加了一个自定义的url参数,修改代码如下: def run(self, isWsgi=False, debug=True, port=80, url='/'): self.isWsgi = isWsgi self.debug = debug if debug: set_logging(loggingLevel=logging.DEBUG) MainHandler = construct_handler(self, isWsgi) app = tornado.web.Application( [(url, MainHandler)], debug=debug) 添加这个url参数,主要是在实际应用中,我使用nginx做代理,微信公众号服务器地址有二级路径,例如:http://vfczq9.natappfree.cc/yl 希望这个功能可以添加到主版本中,目前我是fork了一个版本:https://github.com/dlyili/itchatmp

非常感谢。

dlyili avatar Jun 21 '18 01:06 dlyili

这个怎么没回复,我感觉非常棒的。我也是需要公众号接口有二级路径的,所以按照这个改了一下,非常方便。 @dlyili 你提交 PR 了吗?

我这里放一下完整的 run 函数代码:

def run(self, isWsgi=False, debug=True, port=80, path='/'):
    self.isWsgi = isWsgi
    self.debug = debug
    if debug:
        set_logging(loggingLevel=logging.DEBUG)
    MainHandler = construct_handler(self, isWsgi)
    app = tornado.web.Application(
        [(path, MainHandler)], debug=debug)
    logger.info('itchatmp started!%s' % (
        ' press Ctrl+C to exit.' if debug else ''))
    if isWsgi:
        return WSGIAdapter(app)
    else:
        port = int(port)
        env_test(port)
        app.listen(port)
        try:
            self.ioLoop.start()
        except:
            logger.info('Bye~')
            self.ioLoop.stop()

georgeyjm avatar Sep 24 '18 08:09 georgeyjm