File tree Expand file tree Collapse file tree 2 files changed +12
-12
lines changed
shiny/api-examples/MarkdownStream Expand file tree Collapse file tree 2 files changed +12
-12
lines changed Original file line number Diff line number Diff line change 1111
1212def server (input , output , session ):
1313 # Read in the README.md file from the py-shiny repository
14- response = requests .get (
14+ readme = requests .get (
1515 "https://raw.githubusercontent.com/posit-dev/py-shiny/refs/heads/main/README.md"
1616 )
17- content = response .text .replace ("\n " , " \n " )
17+ readme_chunks = readme .text .replace ("\n " , " \n " ). split ( " " )
1818
1919 # Generate words from the README.md file (with a small delay)
20- def generate_words ():
21- for word in content . split ( " " ) :
20+ def chunk_generator ():
21+ for chunk in readme_chunks :
2222 time .sleep (0.05 )
23- yield word + " "
23+ yield chunk + " "
2424
2525 md = ui .MarkdownStream ("shiny-readme" )
2626 md .ui ()
27- md .stream (generate_words ())
27+ md .stream (chunk_generator ())
2828
2929
3030app = App (app_ui , server )
Original file line number Diff line number Diff line change 55from shiny .express import session , ui
66
77# Read in the README.md file from the py-shiny repository
8- response = requests .get (
8+ readme = requests .get (
99 "https://raw.githubusercontent.com/posit-dev/py-shiny/refs/heads/main/README.md"
1010)
11- content = response .text .replace ("\n " , " \n " )
11+ readme_chunks = readme .text .replace ("\n " , " \n " ). split ( " " )
1212
1313
1414# Generate words from the README.md file (with a small delay)
15- def generate_words ():
16- for word in content . split ( " " ) :
15+ def chunk_generator ():
16+ for chunk in readme_chunks :
1717 if not session .is_stub_session ():
1818 time .sleep (0.05 )
19- yield word + " "
19+ yield chunk + " "
2020
2121
2222md = ui .MarkdownStream ("shiny-readme" )
2323md .ui ()
24- md .stream (generate_words ())
24+ md .stream (chunk_generator ())
You can’t perform that action at this time.
0 commit comments