github-actions[bot] commited on
Commit
a3f924b
Β·
1 Parent(s): 7d59a89

deploy: switch to chatterbox requirements @ d428db2

Browse files
Files changed (1) hide show
  1. server.py +29 -0
server.py CHANGED
@@ -863,3 +863,32 @@ class NoCacheStaticMiddleware(BaseHTTPMiddleware):
863
  return response
864
 
865
  # Standalone middleware and static mounts removed (now handled in app.py/main app)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
863
  return response
864
 
865
  # Standalone middleware and static mounts removed (now handled in app.py/main app)
866
+
867
+
868
+ # ── Local dev entrypoint ──────────────────────────────
869
+ # On HF Spaces `app.py` creates its own Server and imports this router, so
870
+ # the block below is skipped. Locally, `python server.py` builds a minimal
871
+ # FastAPI wrapper around the router so there's something for uvicorn to run.
872
+ if __name__ == "__main__":
873
+ local_app = FastAPI(title="VideoVoice API (local)")
874
+ local_app.state.limiter = limiter
875
+ local_app.add_exception_handler(RateLimitExceeded, _rate_limit_exceeded_handler)
876
+ local_app.add_middleware(SlowAPIMiddleware)
877
+ local_app.add_middleware(NoCacheStaticMiddleware)
878
+ local_app.add_middleware(
879
+ CORSMiddleware,
880
+ allow_origins=ALLOWED_ORIGINS,
881
+ allow_credentials=True,
882
+ allow_methods=["*"],
883
+ allow_headers=["*"],
884
+ )
885
+
886
+ @local_app.middleware("http")
887
+ async def _local_content_length(request: Request, call_next):
888
+ return await enforce_content_length_limit(request, call_next)
889
+
890
+ local_app.include_router(router)
891
+
892
+ import uvicorn
893
+ port = int(os.getenv("PORT", 8000))
894
+ uvicorn.run(local_app, host="0.0.0.0", port=port)