Zhen Ye commited on
Commit
51193fd
·
1 Parent(s): 3de3df3

Add internvl dependency and disable frontend caching

Browse files
Files changed (2) hide show
  1. app.py +14 -0
  2. requirements.txt +1 -1
app.py CHANGED
@@ -89,6 +89,20 @@ app.add_middleware(
89
  allow_headers=["*"],
90
  )
91
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
92
  # Optional: serve the LaserPerception frontend from this backend.
93
  _LASER_DIR = Path(__file__).with_name("LaserPerception")
94
  if _LASER_DIR.exists():
 
89
  allow_headers=["*"],
90
  )
91
 
92
+
93
+ from fastapi import Request
94
+
95
+ @app.middleware("http")
96
+ async def add_no_cache_header(request: Request, call_next):
97
+ """Ensure frontend assets are not cached by the browser (important for HF Spaces updates)."""
98
+ response = await call_next(request)
99
+ # Apply to all static files and the root page
100
+ if request.url.path.startswith("/laser") or request.url.path == "/":
101
+ response.headers["Cache-Control"] = "no-cache, no-store, must-revalidate"
102
+ response.headers["Pragma"] = "no-cache"
103
+ response.headers["Expires"] = "0"
104
+ return response
105
+
106
  # Optional: serve the LaserPerception frontend from this backend.
107
  _LASER_DIR = Path(__file__).with_name("LaserPerception")
108
  if _LASER_DIR.exists():
requirements.txt CHANGED
@@ -13,4 +13,4 @@ timm
13
  ffmpeg-python
14
  python-dotenv
15
  einops
16
-
 
13
  ffmpeg-python
14
  python-dotenv
15
  einops
16
+ internvl