index.py 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. from config import charts_demo_host
  2. from pywebio.output import put_markdown, put_row, put_html
  3. from pywebio.session import info as session_info
  4. index_md = r"""### Basic demo
  5. The source code of the demos can be found [here](https://github.com/pywebio/PyWebIO/tree/dev/demos).
  6. - [BMI calculation](./bmi): Calculating Body Mass Index based on height and weight
  7. - [Online chat room](./chat_room): Chat with everyone currently online (using less than 90 lines of code)
  8. - [Markdown live preview](./markdown_previewer): The online markdown editor with live preview (using less than 40 lines of code)
  9. - [Online Gomoku game](./gomoku_game): An online shared Gomoku game (using less than 100 lines of code)
  10. - [Input demo](./input_usage): Demonstrate the usage of PyWebIO input module
  11. - [Output demo](./output_usage): Demonstrate the usage of PyWebIO output module
  12. - [ChatGPT](./chatgpt): A ChatGPT client implemented with PyWebIO
  13. - [Wordle](./wordle): A wordle-like game implemented with PyWebIO
  14. - [Theme preview](./theme): Demo page with various themes supported by PyWebIO
  15. ### Data visualization demo
  16. PyWebIO supports for data visualization with the third-party libraries.
  17. - Use `bokeh` for data visualization [**demos**]({charts_demo_host}/?app=bokeh)
  18. - Use `plotly` for data visualization [**demos**]({charts_demo_host}/?app=plotly)
  19. - Use `pyecharts` to create Echarts-based charts in Python [**demos**]({charts_demo_host}/?app=pyecharts)
  20. - Use `pyg2plot` to create G2Plot-based charts in Python [**demos**]({charts_demo_host}/?app=pyg2plot)
  21. - Use `cutecharts.py` to create hand drawing style charts [**demos**]({charts_demo_host}/?app=cutecharts)
  22. **Screenshots**
  23. <a href="{charts_demo_host}/?app=bokeh">
  24. <img src="https://fastly.jsdelivr.net/gh/wang0618/pywebio-chart-gallery/assets/bokeh.png" alt="bokeh demo">
  25. </a>
  26. <a href="{charts_demo_host}/?app=plotly">
  27. <img src="https://fastly.jsdelivr.net/gh/wang0618/pywebio-chart-gallery/assets/plotly.png" alt="plotly demo">
  28. </a>
  29. <a href="{charts_demo_host}/?app=pyecharts">
  30. <img src="https://fastly.jsdelivr.net/gh/wang0618/pywebio-chart-gallery/assets/pyecharts.gif" alt="pyecharts demo">
  31. </a>
  32. <a href="{charts_demo_host}/?app=cutecharts">
  33. <img src="https://fastly.jsdelivr.net/gh/wang0618/pywebio-chart-gallery/assets/cutecharts.png" alt="cutecharts demo">
  34. </a>
  35. ### Links
  36. * PyWebIO Github [github.com/wang0618/PyWebIO](https://github.com/wang0618/PyWebIO)
  37. * Document [pywebio.readthedocs.io](https://pywebio.readthedocs.io)
  38. * [PyWebIO Playground](https://play.pywebio.online/): Edit, Run, Share PyWebIO Code Online
  39. """.format(charts_demo_host=charts_demo_host)
  40. index_md_zh = r"""### 基本demo
  41. Demo源码[链接](https://github.com/pywebio/PyWebIO/tree/dev/demos)
  42. - [BMI计算](./bmi): 根据身高体重计算BMI指数
  43. - [聊天室](./chat_room): 和当前所有在线的人聊天 (不到90行代码实现)
  44. - [Markdown实时预览](./markdown_previewer): 可以实时预览的在线Markdown编辑器 (不到40行代码实现)
  45. - [在线五子棋游戏](./gomoku_game): 多人协作对战的五子棋游戏 (不到100行代码实现)
  46. - [输入演示](./input_usage): 演示PyWebIO输入模块的用法
  47. - [输出演示](./output_usage): 演示PyWebIO输出模块的用法
  48. - [ChatGPT](./chatgpt): 使用PyWebIO编写的ChatGPT客户端
  49. - [Wordle](./wordle): 使用PyWebIO编写的猜字游戏(wordle)
  50. - [主题预览](./theme): 展示PyWebIO支持的各种主题
  51. - 更多Demo请见[文档](https://pywebio.readthedocs.io)中示例代码的在线Demo
  52. ### 数据可视化demo
  53. PyWebIO还支持使用第三方库进行数据可视化
  54. - 使用`bokeh`进行数据可视化 [**demos**]({charts_demo_host}/?app=bokeh)
  55. - 使用`plotly`进行数据可视化 [**demos**]({charts_demo_host}/?app=plotly)
  56. - 使用`pyecharts`创建基于Echarts的图表 [**demos**]({charts_demo_host}/?app=pyecharts)
  57. - 使用`pyg2plot`创建基于G2Plot的图表 [**demos**]({charts_demo_host}/?app=pyg2plot)
  58. - 使用`cutecharts.py`创建卡通风格图表 [**demos**]({charts_demo_host}/?app=cutecharts)
  59. **数据可视化demo截图**
  60. <a href="{charts_demo_host}/?app=bokeh">
  61. <img src="https://fastly.jsdelivr.net/gh/wang0618/pywebio-chart-gallery/assets/bokeh.png" alt="bokeh demo">
  62. </a>
  63. <a href="{charts_demo_host}/?app=plotly">
  64. <img src="https://fastly.jsdelivr.net/gh/wang0618/pywebio-chart-gallery/assets/plotly.png" alt="plotly demo">
  65. </a>
  66. <a href="{charts_demo_host}/?app=pyecharts">
  67. <img src="https://fastly.jsdelivr.net/gh/wang0618/pywebio-chart-gallery/assets/pyecharts.gif" alt="pyecharts demo">
  68. </a>
  69. <a href="{charts_demo_host}/?app=cutecharts">
  70. <img src="https://fastly.jsdelivr.net/gh/wang0618/pywebio-chart-gallery/assets/cutecharts.png" alt="cutecharts demo">
  71. </a>
  72. ### Links
  73. * PyWebIO Github [github.com/wang0618/PyWebIO](https://github.com/wang0618/PyWebIO)
  74. * 使用手册和实现文档见 [pywebio.readthedocs.io](https://pywebio.readthedocs.io/zh_CN/latest/)
  75. * [PyWebIO Playground](https://play.pywebio.online/): 在线编辑、运行和分享PyWebIO代码
  76. """.format(charts_demo_host=charts_demo_host)
  77. def main():
  78. """PyWebIO demos
  79. Basic demo and data visualization demo of PyWebIO.
  80. PyWebIO的基本demo和数据可视化demo
  81. """
  82. put_row([
  83. put_markdown('# PyWebIO demos'),
  84. put_html(
  85. '<a class="github-button" data-size="large" href="https://github.com/wang0618/PyWebIO" data-show-count="true" aria-label="Star wang0618/PyWebIO on GitHub">Star</a>')
  86. ], size='1fr auto').style('align-items:center')
  87. put_html('<script async defer src="https://buttons.github.io/buttons.js"></script>')
  88. if 'zh' in session_info.user_language:
  89. put_markdown(index_md_zh)
  90. else:
  91. put_markdown(index_md)