Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/363.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 烧瓶url\u前缀生成重复url?_Python_Flask - Fatal编程技术网

Python 烧瓶url\u前缀生成重复url?

Python 烧瓶url\u前缀生成重复url?,python,flask,Python,Flask,我在提交表单时使用flask url_前缀时遇到一些问题。在模板中似乎没有使用前缀,如果我手动添加前缀,它将复制url\u前缀。。这就是我的意思 mod_auth = Blueprint('auth', __name__, url_prefix='/auth') @mod_auth.route('/signup', methods=['GET', 'POST']) def home_page(): if request.method == 'GET': # This works wh

我在提交表单时使用flask url_前缀时遇到一些问题。在模板中似乎没有使用前缀,如果我手动添加前缀,它将复制url\u前缀。。这就是我的意思

mod_auth = Blueprint('auth', __name__, url_prefix='/auth')


@mod_auth.route('/signup', methods=['GET', 'POST'])
def home_page():
    if request.method == 'GET': # This works when navigating to /auth/signup
        return render_template('/auth/signup.html')
    elif request.method == 'POST':
       print('test')
       form_signup()
在我的模板中

<form action="/signup" method="post"> # This does not 
# work when submitting. It just trys to go to /signup not auth/signup
任何帮助都将不胜感激。我似乎找不到这方面的任何信息。

我找到了

模板需要另一个正斜杠

<form action="/auth/signup" method="post"> 

或者您可以使用
url\u for()
函数:

<form action="{{url_for('mod_auth.home_page')}}" method="post">

<form action="/auth/signup" method="post"> 
<form action="{{url_for('mod_auth.home_page')}}" method="post">