中文字幕av专区_日韩电影在线播放_精品国产精品久久一区免费式_av在线免费观看网站

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

Flask error: werkzeug.routing.BuildError

發布時間:2020-07-19 19:20:55 來源:網絡 閱讀:1671 作者:DevOperater 欄目:開發技術


@main.route('/sendfile', methods=['GET', 'POST'])
def sendfile():
    if request.method == 'POST':
        f = request.files['file']
        basepath = path.abspath(path.dirname(__file__))
        upload_path = path.join(basepath, 'static/uploads')
        f.save(upload_path + '/' + secure_filename(f.filename))
        return redirect(url_for('sendfile'))
    return render_template('sendfile.html')





^CwulilideMacBook-Pro:Manage root# python Manage.py runserver

 * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)

 * Restarting with stat

127.0.0.1 - - [21/Nov/2016 18:24:31] "GET /sendfile HTTP/1.1" 200 -

127.0.0.1 - - [21/Nov/2016 18:24:32] "GET / HTTP/1.1" 200 -

127.0.0.1 - - [21/Nov/2016 18:24:32] "GET / HTTP/1.1" 200 -

127.0.0.1 - - [21/Nov/2016 18:24:34] "GET /sendfile HTTP/1.1" 200 -

127.0.0.1 - - [21/Nov/2016 18:24:40] "POST /sendfile HTTP/1.1" 500 -

Traceback (most recent call last):

  File "/Library/Python/2.7/site-packages/flask/app.py", line 1836, in __call__

    return self.wsgi_app(environ, start_response)

  File "/Library/Python/2.7/site-packages/flask/app.py", line 1820, in wsgi_app

    response = self.make_response(self.handle_exception(e))

  File "/Library/Python/2.7/site-packages/flask/app.py", line 1403, in handle_exception

    reraise(exc_type, exc_value, tb)

  File "/Library/Python/2.7/site-packages/flask/app.py", line 1817, in wsgi_app

    response = self.full_dispatch_request()

  File "/Library/Python/2.7/site-packages/flask/app.py", line 1477, in full_dispatch_request

    rv = self.handle_user_exception(e)

  File "/Library/Python/2.7/site-packages/flask/app.py", line 1381, in handle_user_exception

    reraise(exc_type, exc_value, tb)

  File "/Library/Python/2.7/site-packages/flask/app.py", line 1475, in full_dispatch_request

    rv = self.dispatch_request()

  File "/Library/Python/2.7/site-packages/flask/app.py", line 1461, in dispatch_request

    return self.view_functions[rule.endpoint](**req.view_args)

  File "/Users/wulili/myproject/Manage/app/main/views.py", line 25, in sendfile

    return redirect(url_for('sendfile'))

  File "/Library/Python/2.7/site-packages/flask/helpers.py", line 312, in url_for

    return appctx.app.handle_url_build_error(error, endpoint, values)

  File "/Library/Python/2.7/site-packages/flask/app.py", line 1641, in handle_url_build_error

    reraise(exc_type, exc_value, tb)

  File "/Library/Python/2.7/site-packages/flask/helpers.py", line 305, in url_for

    force_external=external)

  File "/Library/Python/2.7/site-packages/werkzeug/routing.py", line 1678, in build

    raise BuildError(endpoint, values, method)

BuildError: ('sendfile', {}, None)

127.0.0.1 - - [21/Nov/2016 18:24:40] "GET /sendfile?__debugger__=yes&cmd=resource&f=style.css HTTP/1.1" 200 -

127.0.0.1 - - [21/Nov/2016 18:24:40] "GET /sendfile?__debugger__=yes&cmd=resource&f=jquery.js HTTP/1.1" 200 -

127.0.0.1 - - [21/Nov/2016 18:24:40] "GET /sendfile?__debugger__=yes&cmd=resource&f=debugger.js HTTP/1.1" 200 -

127.0.0.1 - - [21/Nov/2016 18:24:40] "GET /sendfile?__debugger__=yes&cmd=resource&f=console.png HTTP/1.1" 200 -

127.0.0.1 - - [21/Nov/2016 18:24:40] "GET /sendfile?__debugger__=yes&cmd=resource&f=source.png HTTP/1.1" 200 -

127.0.0.1 - - [21/Nov/2016 18:24:40] "GET /sendfile?__debugger__=yes&cmd=resource&f=ubuntu.ttf HTTP/1.1" 200 -

127.0.0.1 - - [21/Nov/2016 18:24:40] "GET /sendfile?__debugger__=yes&cmd=resource&f=console.png HTTP/1.1" 200 -

 * Detected change in '/Users/wulili/myproject/Manage/app/main/views.py', reloading

 * Restarting with stat



解決方法:


if you are using blueprints, url_for should be invoked as url_for(blueprint_name.func_name).

main 為藍圖的名字

修改后的代碼為



@main.route('/sendfile', methods=['GET', 'POST'])
def sendfile():
   if request.method == 'POST':
       f = request.files['file']
       basepath = path.abspath(path.dirname(__file__))
       upload_path = path.join(basepath, 'static/uploads')
       f.save(upload_path + '/' + secure_filename(f.filename))
       return redirect(url_for('main.sendfile'))
   return render_template('sendfile.html')


向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

松原市| 涡阳县| 白水县| 西吉县| 双城市| 南宁市| 丰原市| 万宁市| 西畴县| 乐都县| 收藏| 内乡县| 当阳市| 乐平市| 义乌市| 阜城县| 金秀| 涟水县| 米脂县| 临高县| 兴安县| 灯塔市| 南岸区| 科技| 东山县| 靖州| 嘉荫县| 枣庄市| 寿光市| 葵青区| 台南县| 宜川县| 台江县| 连平县| 柘城县| 天台县| 香港| 乌兰察布市| 永清县| 叶城县| 尼木县|