在过去的 45 分钟里,我一直在尝试弄清楚如何在我的 Flask 页面上显示我的图标。
这是我当前的代码:
from flask import Flask, render_template, send_from_directory, url_for
import os
app = Flask(__name__)
@app.route("/")
def home():
return render_template("index.html")
@app.route("/store")
def store():
return render_template("store.html")
@app.route("/games")
def games():
return render_template("games.html")
@app.route("/americanstudios")
def americanstudios():
return render_template("as.html")
@app.route("/pear")
def pear():
return render_template("pear.html")
@app.route("/favicon.ico")
def fav():
return send_from_directory(os.path.join(app.root_path, 'static'), 'favicon.ico', minetype='image/vnd.microsof.icon')
if __name__ == "__main__":
app.run(debug=True)
Run Code Online (Sandbox Code Playgroud)
基本 html 是这样的:
<!DOCTYPE html>
<html>
<title>{% block title %}{% endblock %}</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Raleway"> …Run Code Online (Sandbox Code Playgroud)