Skip to content

Commit 1febecc

Browse files
committed
feat(pems): integrate sample Streamlit app
show the bikeshare sample in an iframe in a Django template served by a Django route/view
1 parent d7976a2 commit 1febecc

File tree

6 files changed

+22
-1
lines changed

6 files changed

+22
-1
lines changed

pems/settings.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ def _filter_empty(ls):
3131
"django.contrib.sessions",
3232
"django.contrib.messages",
3333
"django.contrib.staticfiles",
34+
"pems.streamlit_sample",
3435
]
3536

3637
MIDDLEWARE = [

pems/streamlit_sample/__init__.py

Whitespace-only changes.

pems/streamlit_sample/apps.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
from django.apps import AppConfig
2+
3+
4+
class CoreAppConfig(AppConfig):
5+
name = "pems.streamlit_sample"
6+
label = "streamlit_sample"
7+
verbose_name = "Streamlit sample"
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<h1>Streamlit inside Django</h1>
2+
3+
<iframe
4+
src="http://localhost:8501/sample--bikeshare?embed=true"
5+
style="height: 100%; width: 100%;">
6+
</iframe>

pems/streamlit_sample/urls.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
from django.urls import path
2+
from django.views.generic import TemplateView
3+
4+
urlpatterns = [
5+
path("", TemplateView.as_view(template_name="streamlit_sample/index.html")),
6+
]

pems/urls.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@
1616
"""
1717

1818
from django.contrib import admin
19-
from django.urls import path
19+
from django.urls import include, path
2020

2121
urlpatterns = [
2222
path("admin/", admin.site.urls),
23+
path("streamlit/", include("pems.streamlit_sample.urls")),
2324
]

0 commit comments

Comments
 (0)