Skip to content

Commit 524cce8

Browse files
committed
Move images to API
1 parent 64929e5 commit 524cce8

File tree

481 files changed

+47
-49
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

481 files changed

+47
-49
lines changed

.gitignore

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
__pycache__
22

3+
api/assets/markers/*.svg
4+
api/assets/marker-gl-sprite*
5+
api/assets/node_modules/
6+
37
web/po/mo
48
web/po/osmose-frontend.pot.tmp
59
web/po/tmp.tpl
@@ -11,16 +15,8 @@ web_api/public/
1115
web_api/static/images
1216
web_api/static/node_modules
1317

14-
web/static/.webassets-cache/
15-
web/static/gen/
16-
web/static/osmose-coverage.json*
17-
web/static/osmose-coverage.topojson.pbf*
18-
19-
web/node_modules
2018
osmose-frontend-venv
2119

22-
web/public/assets
23-
2420
.mypy_cache
2521

2622
docker/.env

INSTALL.md

Lines changed: 2 additions & 2 deletions

api/app.py

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
from fastapi import FastAPI
1+
import os
2+
3+
from fastapi import FastAPI, HTTPException, Response
24
from fastapi.middleware.cors import CORSMiddleware
35
from fastapi.openapi.utils import get_openapi
46

@@ -106,3 +108,35 @@ async def startup() -> None:
106108
app.include_router(issues.router)
107109
app.include_router(issues_tiles.router)
108110
app.include_router(false_positive.router)
111+
112+
113+
@app.get("/0.3/assets/sprites.css")
114+
def sprites_css():
115+
file_path = "api/assets/sprites.css"
116+
if os.path.isfile(file_path):
117+
return Response(open(file_path, "rb").read())
118+
else:
119+
raise HTTPException(status_code=404)
120+
121+
122+
@app.get("/0.3/assets/sprite.png")
123+
def sprite_png():
124+
return Response(open("api/assets/sprite.png", "rb").read())
125+
126+
127+
@app.get("/0.3/assets/marker-gl-sprite.json")
128+
def marker_gl_sprite_json():
129+
return Response(open("api/assets/marker-gl-sprite.json", "rb").read())
130+
131+
132+
@app.get("/0.3/assets/marker-gl-sprite.png")
133+
def marker_gl_sprite_png():
134+
return Response(open("api/assets/marker-gl-sprite.png", "rb").read())
135+
136+
137+
@app.get("/0.3/assets/markers/{filename:path}.png")
138+
def marker(filename):
139+
file_path = f"api/markers/{filename}.png"
140+
if not os.path.isfile(file_path):
141+
file_path = "api/markers/marker-b-0.png"
142+
return Response(open(file_path, "rb").read())
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)