Skip to content

Commit

Permalink
cache bust
Browse files Browse the repository at this point in the history
  • Loading branch information
jwoglom committed Aug 27, 2024
1 parent 9ea4017 commit e1359d9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import time
import asyncio
import random
from urllib.parse import urlparse

from flask import Flask, Response, request, abort, redirect, jsonify, render_template, send_from_directory

Expand Down Expand Up @@ -53,9 +54,11 @@ def grab_src(filt=None):

@app.route('/')
def index():
cache_bust = str(urlparse(request.url).query or '').split('&ts=')[0] + '&ts=' + str(int(time.time()))
return render_template('index.html',
seconds=request.params.get('seconds', os.getenv('SECONDS', 300)),
src=grab_src(request.params.get('filter', None)))
cache_bust=cache_bust,
seconds=request.args.get('seconds', os.getenv('SECONDS', 300)),
src=grab_src(request.args.get('filter', None)))

@app.route('/videos/<path:path>')
def render_static(path):
Expand Down
2 changes: 1 addition & 1 deletion templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
background: black;
}
</style>
<meta http-equiv="refresh" content="{{ seconds }}" />
<meta http-equiv="refresh" content="{{ seconds }}; url=?{{ cache_bust }}" />
</head>
<body>
<video playsinline autoplay muted loop src="{{ src }}"></video>
Expand Down

0 comments on commit e1359d9

Please sign in to comment.