Skip to content

Commit 99a8c45

Browse files
committed
fix: prefix /api to avoid rewrite rules in ingress
1 parent ddbe8ab commit 99a8c45

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

main.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import os
22

3-
from fastapi import FastAPI
3+
from fastapi import FastAPI, Request
44

55
app = FastAPI()
66

77

8-
@app.get("/")
9-
def read_root():
8+
@app.get("/api")
9+
def read_root(request: Request):
1010
# list all env vars starting with HELLO-
1111
hello_env_vars = {k: v for k, v in os.environ.items() if k.startswith("HELLO_")}
12-
return {"message": "Hello, World!", "envs": hello_env_vars}
12+
headers = dict(request.headers)
13+
return {"message": "Hello, World!", "envs": hello_env_vars, "headers": headers}

0 commit comments

Comments
 (0)