我在登录页面中有一个 HTML 表单,我想通过 ajax 将表单数据发送到 /data rout。
问题是在后端验证此 HTML 表单。
我知道 Flask WTF 表单,但使用这种方法会在后端生成表单,这不是我的情况。
from flask import Flask, request, url_for
...
@app.route("/data", methods=["GET", "POST"])
def get_data():
if request.method == "POST":
username = request.form["username"]
...
Run Code Online (Sandbox Code Playgroud)
我的 html 表单:
<form method="POST" action="">
<input type="text" name="username">
<input type="submit" value="Send">
</form>
Run Code Online (Sandbox Code Playgroud)
一种困难的方法是使用正则表达式验证每个字段并为它们编写几个 if 条件。我想知道更简单的方法吗?
我的样式表加载到我的 WordPress 主题中的所有页面上。我想在landing.php中禁用它。该文件位于以下地址:http://example.com/wp-content/uploads/fusion-styles/fusion-22528.css 到目前为止我已经尝试过这些代码:
function themeslug_enqueue_style() {
if (is_page_template( 'landing.php' )) {
wp_enqueue_style( 'stylesheet', 'http://example.com/wp-
content/uploads/fusion-styles/fusion-22528.css', false );
}
}
add_action( 'wp_enqueue_scripts', 'themeslug_enqueue_style' );
Run Code Online (Sandbox Code Playgroud)
和这个:
function se_remove_styles() {
if ( is_page_template( 'landing.php' ) ) {
wp_dequeue_style( 'http://example.com/wp-content/uploads/fusion-
styles/fusion-22528.css?timestamp=1510985246&ver=4.9' );
}
}
add_action( 'wp_print_styles', 'se_remove_styles', 99999 );action(
'wp_print_styles', 'se_remove_all_styles', 999999 );
Run Code Online (Sandbox Code Playgroud)
但没有用。我曾经使用过这个代码:
function se_remove_all_styles() {
global $wp_styles;
if ( is_page_template( 'landing.php' ) ) {
$wp_styles->queue = array();
}
}
add_action( 'wp_print_styles', 'se_remove_all_styles', 99 );
Run Code Online (Sandbox Code Playgroud)
但它会删除我所有的样式。
任何帮助将不胜感激。