File tree Expand file tree Collapse file tree 3 files changed +18
-1
lines changed
api-examples/download_button Expand file tree Collapse file tree 3 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
8
8
9
9
## [ UNRELEASED]
10
10
11
+ * Fixed ` render.download ` not working in Express. (#1085 )
11
12
12
13
13
14
## [ 0.7.0] - 2024-01-25
Original file line number Diff line number Diff line change
1
+ import asyncio
2
+ import random
3
+ from datetime import date
4
+
5
+ from shiny .express import render
6
+
7
+
8
+ @render .download (
9
+ filename = lambda : f"新型-{ date .today ().isoformat ()} -{ random .randint (100 ,999 )} .csv"
10
+ )
11
+ async def downloadData ():
12
+ await asyncio .sleep (0.25 )
13
+ yield "one,two,three\n "
14
+ yield "新,1,2\n "
15
+ yield "型,4,5\n "
Original file line number Diff line number Diff line change 30
30
from .._docstring import add_example , no_example
31
31
from .._namespaces import ResolvedId
32
32
from .._typing_extensions import Self
33
+ from ..express ._mock_session import MockSession
33
34
from ..session import get_current_session , require_active_session
34
35
from ..session ._session import DownloadHandler , DownloadInfo
35
36
from ..types import MISSING , MISSING_TYPE , ImgData
@@ -688,7 +689,7 @@ def url() -> str:
688
689
# not being None is because in Express, when the UI is rendered, this function
689
690
# `render.download()()` called once before any sessions have been started.
690
691
session = get_current_session ()
691
- if session is not None :
692
+ if session is not None and not isinstance ( session , MockSession ) :
692
693
session ._downloads [self .output_id ] = DownloadInfo (
693
694
filename = self .filename ,
694
695
content_type = self .media_type ,
You can’t perform that action at this time.
0 commit comments