eshan6704 commited on
Commit
1b22726
·
verified ·
1 Parent(s): 89fb9e5

Update app/app.py

Browse files
Files changed (1) hide show
  1. app/app.py +13 -0
app/app.py CHANGED
@@ -1,10 +1,12 @@
1
  from fastapi.responses import HTMLResponse
2
  from fastapi import FastAPI, HTTPException
3
  from fastapi.middleware.cors import CORSMiddleware
 
4
  from pydantic import BaseModel
5
  import os
6
  import importlib.util
7
 
 
8
  # -------------------------------------------------------
9
  #
10
  # -------------------------------------------------------
@@ -28,7 +30,11 @@ from . import yahooinfo
28
  # FastAPI app
29
  # -------------------------------------------------------
30
  app = FastAPI(title="Stock / Index Backend")
 
31
 
 
 
 
32
  app.add_middleware(
33
  CORSMiddleware,
34
  allow_origins=["*"],
@@ -36,6 +42,13 @@ app.add_middleware(
36
  allow_headers=["*"],
37
  )
38
 
 
 
 
 
 
 
 
39
  # -------------------------------------------------------
40
  # Valid request types
41
  # -------------------------------------------------------
 
1
  from fastapi.responses import HTMLResponse
2
  from fastapi import FastAPI, HTTPException
3
  from fastapi.middleware.cors import CORSMiddleware
4
+ from fastapi.middleware.gzip import GZipMiddleware # ✅ Add this
5
  from pydantic import BaseModel
6
  import os
7
  import importlib.util
8
 
9
+
10
  # -------------------------------------------------------
11
  #
12
  # -------------------------------------------------------
 
30
  # FastAPI app
31
  # -------------------------------------------------------
32
  app = FastAPI(title="Stock / Index Backend")
33
+ app = FastAPI(title="Stock / Index Backend")
34
 
35
+ # -------------------------------
36
+ # Existing CORS middleware
37
+ # -------------------------------
38
  app.add_middleware(
39
  CORSMiddleware,
40
  allow_origins=["*"],
 
42
  allow_headers=["*"],
43
  )
44
 
45
+ # -------------------------------
46
+ # 🔥 Add GZip middleware here
47
+ # -------------------------------
48
+ # Compress all responses larger than 1 KB automatically
49
+ app.add_middleware(GZipMiddleware, minimum_size=1000)
50
+
51
+
52
  # -------------------------------------------------------
53
  # Valid request types
54
  # -------------------------------------------------------