Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

自定义路由改进 #47

Open
dlyili opened this issue Jun 21, 2018 · 1 comment
Open

自定义路由改进 #47

dlyili opened this issue Jun 21, 2018 · 1 comment

Comments

@dlyili
Copy link

dlyili commented Jun 21, 2018

我修改了 \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

非常感谢。

@georgeyjm
Copy link

这个怎么没回复,我感觉非常棒的。我也是需要公众号接口有二级路径的,所以按照这个改了一下,非常方便。 @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()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants