-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #157 from spraakbanken/fix-statics
fix statics
- Loading branch information
Showing
13 changed files
with
205 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
[http] | ||
[http.middlewares] | ||
|
||
[http.middlewares.api-stripprefix.stripPrefix] | ||
prefixes = ["/ws/saldo-ws"] | ||
|
||
[http.routers] | ||
|
||
[http.routers.app-http] | ||
entryPoints = ["http"] | ||
service = "app" | ||
rule = "PathPrefix(`/ws/saldo-ws`)" | ||
middlewares = ["api-stripprefix"] | ||
|
||
[http.services] | ||
|
||
[http.services.app] | ||
[http.services.app.loadBalancer] | ||
[[http.services.app.loadBalancer.servers]] | ||
url = "http://127.0.0.1:8000" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[entryPoints] | ||
[entryPoints.http] | ||
address = ":9999" | ||
|
||
[providers] | ||
[providers.file] | ||
filename = "contrib/traefik/routes.toml" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
from fastapi import APIRouter | ||
from fastapi.responses import FileResponse | ||
|
||
router = APIRouter() | ||
|
||
|
||
@router.get("/static{path:path}", name="static") | ||
async def staticfiles_workaround(path: str) -> FileResponse: | ||
return FileResponse(path=f"static{path}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
from fastapi import APIRouter | ||
from fastapi.responses import FileResponse | ||
|
||
router = APIRouter() | ||
|
||
|
||
@router.get("/static{path:path}", response_class=FileResponse, name="static") | ||
async def staticfiles_workaround(path: str): | ||
return f"static{path}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import pytest | ||
from fastapi import status | ||
from httpx import AsyncClient | ||
|
||
|
||
class TestStaticRoutes: | ||
@pytest.mark.asyncio | ||
async def test_static_saldo_css_returns_200(self, client: AsyncClient) -> None: | ||
res = await client.get("/static/saldo.css") | ||
assert res.status_code == status.HTTP_200_OK | ||
|
||
@pytest.mark.asyncio | ||
async def test_root_path_and_static_saldo_css_returns_200( | ||
self, client_w_root_path: AsyncClient | ||
) -> None: | ||
res = await client_w_root_path.get("/static/saldo.css") | ||
assert res.status_code == status.HTTP_200_OK |
Oops, something went wrong.