Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion frameworks/fastapi/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
COPY . .
EXPOSE 8080 8081
CMD [ "python3", "launcher.py", "uvicorn", "app:app", "--host", "0.0.0.0", "--port", "8080", "--loop", "uvloop", "--log-level", "critical" ]
CMD [ "python3", "launcher.py", "uvicorn", "app:app", "--host", "0.0.0.0", "--port", "8080", "--loop", "uvloop", "--log-level", "critical", "--no-server-header", "--header", "Server:FastAPI" ]
11 changes: 1 addition & 10 deletions frameworks/fastapi/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
from fastapi import FastAPI, Request, Response, Path, Query, HTTPException
from fastapi.responses import PlainTextResponse, JSONResponse
from fastapi.middleware.gzip import GZipMiddleware
from fastapi.applications import BaseHTTPMiddleware
from fastapi.staticfiles import StaticFiles


Expand Down Expand Up @@ -74,15 +73,7 @@ async def lifespan(application: FastAPI):

app = FastAPI(lifespan=lifespan)

app.add_middleware(GZipMiddleware, minimum_size=1, compresslevel=5)

class ServerHeaderMiddleware(BaseHTTPMiddleware):
async def dispatch(self, request, call_next):
response = await call_next(request)
response.headers["Server"] = "FastAPI"
return response

app.add_middleware(ServerHeaderMiddleware)
app.add_middleware(GZipMiddleware, minimum_size=1000, compresslevel=5)


# -- Routes ------------------------------------------------------------------
Expand Down
Loading