如何在pywebio start_server中定义origin_check
我有一个小测试脚本,我想在其中检查 pywebio start_server 参数。但 allowed_origins
和 check_origin
在我的脚本中似乎都不起作用:
from pywebio import start_server
from pywebio.input import *
from pywebio.output import *
def main():
put_markdown("## just a small start_server test")
def my_origin_check(value):
print(value)
return False
if __name__ == '__main__':
start_server(main, check_origin=my_origin_check, debug=True, port=5000)
我看不出 my_origin_check
没有被调用的原因 - 我'我眼睛瞎了……有什么帮助吗?
I have a small test script where I'd like to check the pywebio start_server arguments. But neither allowed_origins
nor check_origin
seems to work in my script:
from pywebio import start_server
from pywebio.input import *
from pywebio.output import *
def main():
put_markdown("## just a small start_server test")
def my_origin_check(value):
print(value)
return False
if __name__ == '__main__':
start_server(main, check_origin=my_origin_check, debug=True, port=5000)
I can't see the reason why my_origin_check
doesn't get called - I'm blind on my eyes ... any help?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
根据源代码的
start_server()
:仅当应用程序 url 和底层 websocket api 不在同一主机上时,才会调用用户定义的
check_origin
函数According to the source code of
start_server()
:the user-defined
check_origin
function only is called when the application url and the underlying websocket api is not on same host