From e04566016e7d52f596af92e8df2a468efa9c1e1b Mon Sep 17 00:00:00 2001 From: Dave Whiteland <davewhiteland@users.noreply.github.com> Date: Tue, 18 Mar 2025 21:12:02 +0000 Subject: [PATCH] add a favicon with 24-hour cache --- app.py | 18 +++++++++++++++++- static/favicon.png | Bin 0 -> 123 bytes templates/base.html | 1 + 3 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 static/favicon.png diff --git a/app.py b/app.py index 2b27c81..8ff30f5 100644 --- a/app.py +++ b/app.py @@ -1,4 +1,4 @@ -from flask import Flask, jsonify, render_template, request +from flask import Flask, jsonify, render_template, request, send_file import sqlite3 as sql # the flask application: uses the webserver imported from the flask module: @@ -76,6 +76,22 @@ def send_buggy_json(): {key: val for key, val in buggies if not (val == "" or val is None)} ) +#----------------------------------------------------------------------------- +# send the favicon for the buggy editor: +# This sends the browser an icon image with a cache "time to live" of 24 hours, +# so you shouldn't see this being requested too often while you're debugging. +# There's no template here because it's sending a file straight back. +# (Usually you'd let Flask send images back as static content but this route +# adds the cache header as a special case). +#----------------------------------------------------------------------------- +@app.route("/favicon.png") +def send_favicon(): + return send_file( + "static/favicon.png", + mimetype='image/png', + max_age=60*60*24 + ) + #------------------------------------------------------------ # finally, after all the set-up above, run the app: # This listens to the port for incoming HTTP requests, and sends a response diff --git a/static/favicon.png b/static/favicon.png new file mode 100644 index 0000000000000000000000000000000000000000..d0d77559051c1817db1ddea7bf039bf37090e46a GIT binary patch literal 123 zcmeAS@N?(olHy`uVBq!ia0y~yVAuk}jLZxS4D8HP3K<v}*aCb)T>t-NU|?YQ$lmsz zfq}um)5S5Qg7NJMLq-M#9_9^}hpi?R7}(8dn0IofRG9to>i4y8_J05SR%*}pd)4oq Z>lu5bIb~DLXXk*-@O1TaS?83{1OVdPCv5-# literal 0 HcmV?d00001 diff --git a/templates/base.html b/templates/base.html index 51e01ae..8d268f2 100644 --- a/templates/base.html +++ b/templates/base.html @@ -3,6 +3,7 @@ <head> <meta charset="utf-8" /> <link href="static/app.css" media="screen, projector, print" rel="stylesheet" type="text/css" /> + <link rel="icon" href="/favicon.png" /> </head> <body> <div class="main-content"> -- GitLab