簡體   English   中英

'favicon.ico'FileNotFoundError:[WinError 3]

[英]'favicon.ico' FileNotFoundError: [WinError 3]

如何避免在以下flask代碼中找不到“ favicon.ico”錯誤? 我搜索了幾個favicon.ico問題,但無法解決此問題。

 @app.route('/<path:req_path>')
 def dir_listing(req_path):
    abs_path = os.path.join(UPLOAD_FOLDER, req_path)
    # Check if path is a file and serve
    if os.path.isfile(abs_path):
        return send_file(abs_path, mimetype="application/json")
    # Show directory contents
    files = os.listdir(abs_path)
    return render_template('file_list.html', files=files)

的index.html

<!doctype html>
<title>Upload new File</title>

<hr>
    <link rel="shortcut icon" href="#" />
<h1>{{message}}</h1>

<form action="" method=post enctype=multipart/form-data>
    <p><input type=file name=file>
    <input type=submit value=Upload>
</form>

 <ul>
    {% for file in file_list %}
    <li><a href="{{ file }}">{{ file }}</a></li>
    {% endfor %}
 </ul>

file_list.html-

  <ul>
      {% for file in files %}
         <li>
           <a href="{{ file }}">{{ file }}</a>
         </li>
      {% endfor %}
  </ul>

默認情況下,瀏覽器在打開網站時始終會查找/favicon.ico ,您需要在此提供favicon文件來消除該錯誤。

您還可以按照本指南自定義路徑

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM