Skip to content

Commit

Permalink
Fix: Adding favicon to Kedro Demo (#1509)
Browse files Browse the repository at this point in the history
* Fix: Adding favicon to Kedro Demo

* Fix: Change in approach for serving favicon

* Lint error fix

* Lint error fix

* Favicon endpoint test added

* Favicon endpoint test added

* Lint error fixed

* Fix: Adding favicon to Kedro Demo

Signed-off-by: Jitendra Gundaniya <[email protected]>

* Fix: Change in approach for serving favicon

Signed-off-by: Jitendra Gundaniya <[email protected]>

* Lint error fix

Signed-off-by: Jitendra Gundaniya <[email protected]>

* Lint error fix

Signed-off-by: Jitendra Gundaniya <[email protected]>

* Favicon endpoint test added

Signed-off-by: Jitendra Gundaniya <[email protected]>

* Favicon endpoint test added

Signed-off-by: Jitendra Gundaniya <[email protected]>

* Lint error fixed

Signed-off-by: Jitendra Gundaniya <[email protected]>

* Fixed favicon endpoint test

* Release doc updated

* Update RELEASE.md

Co-authored-by: rashidakanchwala <[email protected]>

* Removed pytest.fixture as per review comment

---------

Signed-off-by: Jitendra Gundaniya <[email protected]>
Co-authored-by: rashidakanchwala <[email protected]>
Signed-off-by: Vladimir <[email protected]>
  • Loading branch information
2 people authored and vladimir-mck committed Sep 6, 2023
1 parent 1e96cb8 commit 703df4f
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
2 changes: 2 additions & 0 deletions RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@ Please follow the established format:
## Bug fixes and other changes

- Fix to search for a '<lambda' Python function in the sidebar. (#1497)
- Add favicon to Kedro-Viz. (#1509)
- Remove python upper-bound requirements and add KedroVizPythonVersion warning. (#1506)
- Resolved various bugs affecting server-side rendering, updated dependencies to ensure compatibility with Vite and Next.js environments (#1508)


# Release 6.4.0

## Major features and improvements
Expand Down
7 changes: 6 additions & 1 deletion package/kedro_viz/api/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import secure
from fastapi import FastAPI, HTTPException
from fastapi.requests import Request
from fastapi.responses import HTMLResponse, JSONResponse, Response
from fastapi.responses import FileResponse, HTMLResponse, JSONResponse, Response
from fastapi.staticfiles import StaticFiles
from jinja2 import Environment, FileSystemLoader

Expand Down Expand Up @@ -72,6 +72,11 @@ def create_api_app_from_project(
# this is used as an etag embedded in the frontend for client to use when making requests.
app_etag = _create_etag()

# Serve the favicon.ico file from the "html" directory
@app.get("/favicon.ico", include_in_schema=False)
async def favicon():
return FileResponse(_HTML_DIR / "favicon.ico")

@app.get("/")
@app.get("/experiment-tracking")
async def index():
Expand Down
10 changes: 10 additions & 0 deletions package/tests/test_api/test_apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,13 @@ def test_reload_endpoint_return_304_when_content_has_not_changed(
# when the etag has changed, the server will return a 200
response = client.get("/api/reload", headers={"If-None-Match": "new etag"})
assert response.status_code == 200


class TestFaviconEndpoint:
def test_favicon_endpoint(self, client):
response = client.get("/favicon.ico")
assert response.status_code == 200
assert response.headers["content-type"] in [
"image/x-icon",
"image/vnd.microsoft.icon",
]

0 comments on commit 703df4f

Please sign in to comment.