giswqs commited on
Commit
546cad5
1 Parent(s): e5de95b

Add solara app

Browse files
Files changed (3) hide show
  1. Dockerfile +12 -6
  2. README.md +1 -0
  3. app.py +28 -0
Dockerfile CHANGED
@@ -1,11 +1,17 @@
1
- FROM python:3.9
 
 
 
 
2
 
3
- WORKDIR /code
4
 
5
- COPY ./requirements.txt /code/requirements.txt
6
 
7
- RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
 
 
8
 
9
- COPY . .
10
 
11
- CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860"]
 
1
+ FROM jupyter/scipy-notebook:latest
2
+ RUN mamba install -c conda-forge leafmap geopandas localtileserver osmnx -y && \
3
+ pip install -U leafmap solara && \
4
+ fix-permissions "${CONDA_DIR}" && \
5
+ fix-permissions "/home/${NB_USER}"
6
 
7
+ COPY app.py app.py
8
 
9
+ ENV PROJ_LIB='/opt/conda/share/proj'
10
 
11
+ USER root
12
+ RUN chown -R ${NB_UID} ${HOME}
13
+ USER ${NB_USER}
14
 
15
+ EXPOSE 8765
16
 
17
+ CMD ["solara", "run", "app.py", "--host=0.0.0.0"]
README.md CHANGED
@@ -6,6 +6,7 @@ colorTo: gray
6
  sdk: docker
7
  pinned: false
8
  license: mit
 
9
  ---
10
 
11
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
6
  sdk: docker
7
  pinned: false
8
  license: mit
9
+ app_port: 8765
10
  ---
11
 
12
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
app.py ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ # ipyleaflet
3
+ Map visualization using [ipyleaflet](https://ipyleaflet.readthedocs.io/), a ipywidgets wrapper for [leaflet.js](https://leafletjs.com/)
4
+ """
5
+ import leafmap
6
+
7
+ import solara
8
+
9
+ zoom = solara.reactive(5)
10
+ center = solara.reactive((53.2305799, 6.5323552))
11
+
12
+
13
+ @solara.component
14
+ def Page():
15
+ with solara.Column(style={"min-width": "500px", "height": "500px"}):
16
+ # solara components support reactive variables
17
+ solara.SliderInt(label="Zoom level", value=zoom, min=1, max=20)
18
+ # using 3rd party widget library require wiring up the events manually
19
+ # using zoom.value and zoom.set
20
+ leafmap.Map.element( # type: ignore
21
+ zoom=zoom.value,
22
+ on_zoom=zoom.set,
23
+ center=center.value,
24
+ on_center=center.set,
25
+ scroll_wheel_zoom=True,
26
+ )
27
+ solara.Text(f"Zoom: {zoom.value}")
28
+ solara.Text(f"Center: {center.value}")