Compare commits
2 Commits
56840ac313
...
b5a0817760
| Author | SHA1 | Date | |
|---|---|---|---|
| b5a0817760 | |||
| 6763fd802c |
28
.github/workflows/ci.yml
vendored
28
.github/workflows/ci.yml
vendored
@@ -24,21 +24,21 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
python-version: ${{ matrix.python-version }}
|
python-version: ${{ matrix.python-version }}
|
||||||
|
|
||||||
- name: Locate pip cache directory
|
# - name: Locate pip cache directory
|
||||||
id: pip-cache-dir
|
# id: pip-cache-dir
|
||||||
# extra output for debugging
|
# # extra output for debugging
|
||||||
run: |
|
# run: |
|
||||||
echo "dir=$(python -m pip cache dir)" >> "$GITHUB_OUTPUT"
|
# echo "dir=$(python -m pip cache dir)" >> "$GITHUB_OUTPUT"
|
||||||
echo "dir=$(python -m pip cache dir)"
|
# echo "dir=$(python -m pip cache dir)"
|
||||||
|
|
||||||
- name: Cache pip
|
# - name: Cache pip
|
||||||
uses: actions/cache@v4
|
# uses: actions/cache@v4
|
||||||
with:
|
# with:
|
||||||
path: ${{ steps.pip-cache-dir.outputs.dir }}
|
# path: ${{ steps.pip-cache-dir.outputs.dir }}
|
||||||
key: ${{ runner.os }}-py-${{ matrix.python-version }}-pip-${{ hashFiles('**/requirements.txt') }}
|
# key: ${{ runner.os }}-py-${{ matrix.python-version }}-pip-${{ hashFiles('**/requirements.txt') }}
|
||||||
restore-keys: |
|
# restore-keys: |
|
||||||
${{ runner.os }}-py-${{ matrix.python-version }}-pip-
|
# ${{ runner.os }}-py-${{ matrix.python-version }}-pip-
|
||||||
${{ runner.os }}-pip-
|
# ${{ runner.os }}-pip-
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
@@ -44,7 +44,8 @@ def register_request_hooks(app: Flask) -> None:
|
|||||||
@app.after_request
|
@app.after_request
|
||||||
def add_request_id_header(response): # type: ignore[unused-ignore]
|
def add_request_id_header(response): # type: ignore[unused-ignore]
|
||||||
try:
|
try:
|
||||||
rid = getattr(request, "request_id", None) or request.environ.get("HTTP_X_REQUEST_ID")
|
rid = getattr(request, "request_id", None) or request.environ.get(
|
||||||
|
"HTTP_X_REQUEST_ID")
|
||||||
if rid:
|
if rid:
|
||||||
response.headers["X-Request-Id"] = rid
|
response.headers["X-Request-Id"] = rid
|
||||||
|
|
||||||
@@ -62,7 +63,27 @@ def register_request_hooks(app: Flask) -> None:
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
start_time = getattr(g, "_start_time", None)
|
start_time = getattr(g, "_start_time", None)
|
||||||
observe_request(request.method, request.path, start_time, response.status_code)
|
observe_request(request.method, request.path,
|
||||||
|
start_time, response.status_code)
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
return response
|
return response
|
||||||
|
|
||||||
|
@app.after_request
|
||||||
|
def add_cors_headers(response): # type: ignore[unused-ignore]
|
||||||
|
# Add CORS headers for embedded forms
|
||||||
|
if request.path.startswith("/api/"):
|
||||||
|
response.headers["Access-Control-Allow-Origin"] = "*"
|
||||||
|
response.headers["Access-Control-Allow-Methods"] = "GET, POST, PUT, DELETE, OPTIONS"
|
||||||
|
response.headers["Access-Control-Allow-Headers"] = "Content-Type, Authorization"
|
||||||
|
|
||||||
|
return response
|
||||||
|
|
||||||
|
@app.before_request
|
||||||
|
def handle_options(): # type: ignore[unused-ignore]
|
||||||
|
if request.method == "OPTIONS":
|
||||||
|
response = app.response_class()
|
||||||
|
response.headers["Access-Control-Allow-Origin"] = "*"
|
||||||
|
response.headers["Access-Control-Allow-Methods"] = "GET, POST, PUT, DELETE, OPTIONS"
|
||||||
|
response.headers["Access-Control-Allow-Headers"] = "Content-Type, Authorization"
|
||||||
|
return response
|
||||||
|
|||||||
Reference in New Issue
Block a user