[Feature Request]单个应用,如何使用@装饰器控制用户验证 #405
Unanswered
nipsevenlovelonglegs
asked this question in
Q&A
Replies: 2 comments
-
其中,
|
Beta Was this translation helpful? Give feedback.
0 replies
-
Thank you for answering my question. I'll try
…------------------ 原始邮件 ------------------
发件人: ***@***.***>;
发送时间: 2022年3月29日(星期二) 晚上9:18
收件人: ***@***.***>;
抄送: ***@***.***>; ***@***.***>;
主题: Re: [pywebio/PyWebIO] [Feature Request]单个应用,如何使用@装饰器控制用户验证 (Issue #289)
webio_view() 函数返回的就是一个flask中的视图函数,所以可以在其上加入视图的装饰器,只不过不能使用@语法,要使用装饰器的原始形态:
app.add_url_rule('/tool', 'webio_view', user(webio_view(task_func)), methods=['GET', 'POST', 'OPTIONS'])
其中,user 为视图的装饰器,如果装饰器可以接收参数,这需要这样调用:
app.add_url_rule('/tool', 'webio_view', user(...)(webio_view(task_func)), methods=['GET', 'POST', 'OPTIONS'])
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
开发一个flask系统,有用户验证, 挂载两个webio制作的应用,如何使用@装饰器,进行用户验证才能打开webio应用呢
rom pywebio.platform.flask import webio_view
from flask import Flask
app = Flask(name)
app.add_url_rule('/tool', 'webio_view', webio_view(task_func),
methods=['GET', 'POST', 'OPTIONS']) # need GET,POST and OPTIONS methods
app.run(host='localhost', port=80)
示例中增加了@user(用户验证装饰器) 并不管用
Beta Was this translation helpful? Give feedback.
All reactions