PyWebIO v0.3.0 使用手册消息: def check_age(p): # 检验函数校验通过时返回None,否则返回错误消息 if p < 10: return 'Too young!!' if p > 60: return 'Too old!!' age = input("How old are you?", type=NUMBER, valid_func=check_age) age', name='age', type=NUMBER, valid_func=check_age) ], valid_func=check_form) print(data['name'], data['age']) 输入组中同样支持设置校验函数,其接受整个表单数据作为参数: def check_form(data): # 检验函数校验通过时返回None,否则返回 (input name ps/wss协议。 跨域配置 当后端API与当前页面不再同一host下时,需要在 webio_handler() 或 webio_view() 中使用 allowed_origins 或 check_origin 参数来使后端接受前端 页面的请求。 基于协程的会话 PyWebIO的会话实现默认是基于线程的,用户每打开一个和服务端的会话连 接,PyWebIO会启动一个线程来运行任务函数,你可以在会话中启动新的线0 码力 | 72 页 | 8.55 MB | 1 年前3
PyWebIO v0.3.0 使用手册None,否则返回错误消息: def check_age(p): # 检验函数校验通过时返回 None,否则返回错误消息 if p < 10: return 'Too young!!' if p > 60: return 'Too old!!' age = input("How old are you?", type=NUMBER, valid_func=check_age) 当用户输入了不合法的值时,页面上的显示如下: type=NUMBER, valid_func=check_age) (下页继续) 4.1. User’s guide 13 PyWebIO, 发布 0.3.0 (续上页) ], valid_func=check_form) print(data['name'], data['age']) 输入组中同样支持设置校验函数,其接受整个表单数据作为参数: def check_form(data): # 检验函数校验通过时返回 https/wss 协议。 跨域配置 当后端 API 与当前页面不再同一 host 下时,需要在webio_handler() 或webio_view() 中使用 allowed_origins 或 check_origin 参数来使后端接受前端页面的请求。 4.1.5 基于协程的会话 PyWebIO 的会话实现默认是基于线程的,用户每打开一个和服务端的会话连接,PyWebIO 会启动一个线程来0 码力 | 70 页 | 1.41 MB | 1 年前3
PyWebIO v1.3.3 Documentationvalidation function should return None when the check passes, otherwise an error message will be returned: def check_age(p): # return None when the check passes, otherwise return the error ˓→message 'Too young!!' if p > 60: return 'Too old!!' age = input("How old are you?", type=NUMBER, validate=check_age) When the user input an illegal value, the input field is displayed as follows: 10 Chapter 4 input('Input your name', name='name'), input('Input your age', name='age', type=NUMBER, validate=check_age) ]) put_text(data['name'], data['age']) The input group also supports using validate parameter0 码力 | 100 页 | 1.34 MB | 1 年前3
PyWebIO v1.3.1 Documentationvalidation function should return None when the check passes, otherwise an error message will be returned: def check_age(p): # return None when the check passes, otherwise return the error ˓→message 'Too young!!' if p > 60: return 'Too old!!' age = input("How old are you?", type=NUMBER, validate=check_age) When the user input an illegal value, the input field is displayed as follows: 10 Chapter 4 input('Input your name', name='name'), input('Input your age', name='age', type=NUMBER, validate=check_age) ]) put_text(data['name'], data['age']) The input group also supports using validate parameter0 码力 | 100 页 | 1.34 MB | 1 年前3
PyWebIO v1.3.0 Documentationvalidation function should return None when the check passes, otherwise an error message will be returned: def check_age(p): # return None when the check passes, otherwise return the error ˓→message 'Too young!!' if p > 60: return 'Too old!!' age = input("How old are you?", type=NUMBER, validate=check_age) When the user input an illegal value, the input field is displayed as follows: 10 Chapter 4 input('Input your name', name='name'), input('Input your age', name='age', type=NUMBER, validate=check_age) ]) put_text(data['name'], data['age']) The input group also supports using validate parameter0 码力 | 100 页 | 1.34 MB | 1 年前3
PyWebIO v1.3.2 Documentationvalidation function should return None when the check passes, otherwise an error message will be returned: def check_age(p): # return None when the check passes, otherwise return the error ˓→message 'Too young!!' if p > 60: return 'Too old!!' age = input("How old are you?", type=NUMBER, validate=check_age) When the user input an illegal value, the input field is displayed as follows: 10 Chapter 4 input('Input your name', name='name'), input('Input your age', name='age', type=NUMBER, validate=check_age) ]) put_text(data['name'], data['age']) The input group also supports using validate parameter0 码力 | 100 页 | 1.34 MB | 1 年前3
PyWebIO v1.6.1 Documentationvalidation function should return None when the check passes, otherwise an error message will be returned: def check_age(p): # return None when the check passes, otherwise return the error ˓→message 'Too young!!' if p > 60: return 'Too old!!' age = input("How old are you?", type=NUMBER, validate=check_age) When the user input an illegal value, the input field is displayed as follows: 10 Chapter 4 input('Input your name', name='name'), input('Input your age', name='age', type=NUMBER, validate=check_age) ]) put_text(data['name'], data['age']) The input group also supports using validate parameter0 码力 | 108 页 | 1.37 MB | 1 年前3
PyWebIO v1.6.2 Documentationvalidation function should return None when the check passes, otherwise an error message will be returned: def check_age(p): # return None when the check passes, otherwise return the error ˓→message 'Too young!!' if p > 60: return 'Too old!!' age = input("How old are you?", type=NUMBER, validate=check_age) When the user input an illegal value, the input field is displayed as follows: 10 Chapter 4 input('Input your name', name='name'), input('Input your age', name='age', type=NUMBER, validate=check_age) ]) put_text(data['name'], data['age']) The input group also supports using validate parameter0 码力 | 108 页 | 1.37 MB | 1 年前3
PyWebIO v1.6.3 Documentationvalidation function should return None when the check passes, otherwise an error message will be returned: def check_age(p): # return None when the check passes, otherwise return the error ˓→message 'Too young!!' if p > 60: return 'Too old!!' age = input("How old are you?", type=NUMBER, validate=check_age) When the user input an illegal value, the input field is displayed as follows: 10 Chapter 4 input('Input your name', name='name'), input('Input your age', name='age', type=NUMBER, validate=check_age) ]) put_text(data['name'], data['age']) The input group also supports using validate parameter0 码力 | 108 页 | 1.37 MB | 1 年前3
PyWebIO v1.6.0 Documentationvalidation function should return None when the check passes, otherwise an error message will be returned: def check_age(p): # return None when the check passes, otherwise return the error ˓→message 'Too young!!' if p > 60: return 'Too old!!' age = input("How old are you?", type=NUMBER, validate=check_age) When the user input an illegal value, the input field is displayed as follows: 10 Chapter 4 input('Input your name', name='name'), input('Input your age', name='age', type=NUMBER, validate=check_age) ]) put_text(data['name'], data['age']) The input group also supports using validate parameter0 码力 | 108 页 | 1.37 MB | 1 年前3
共 86 条
- 1
- 2
- 3
- 4
- 5
- 6
- 9













