大家好,又見面了,我是全棧君。
Python flask設定favicon.ico圖示,如圖:
import os
from flask import Flask
from flask import send_from_directory
from flask import request
app = Flask(__name__)
@app.route('/favicon.ico')#設定icon
def favicon():
return send_from_directory(os.path.join(app.root_path, 'static'),#對于目前檔案所在路徑,比如這裡是static下的favicon.ico
'favicon.ico', mimetype='image/vnd.microsoft.icon')
@app.route('/')
def hello_world():
name=request.args.get("name")#擷取參數對應值
return name
if __name__ == '__main__':
app.run(host='127.0.0.1',port=5000)#本地位址,和端口号
複制
釋出者:全棧程式員棧長,轉載請注明出處:https://javaforall.cn/111383.html原文連結:https://javaforall.cn