index.py 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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. - [BMI calculation](./bmi): Calculating Body Mass Index based on height and weight
  6. - [Online chat room](./chat_room): Chat with everyone currently online (using less than 90 lines of code)
  7. - [Markdown live preview](./markdown_previewer): The online markdown editor with live preview (using less than 40 lines of code)
  8. - [Online Gomoku game](./gomoku_game): An online shared Gomoku game (using less than 100 lines of code)
  9. - [Input demo](./input_usage): Demonstrate the usage of PyWebIO input module
  10. - [Output demo](./output_usage): Demonstrate the usage of PyWebIO output module
  11. ### Data visualization demo
  12. PyWebIO supports for data visualization with the third-party libraries.
  13. - Use `bokeh` for data visualization [**demos**]({charts_demo_host}/?app=bokeh)
  14. - Use `plotly` for data visualization [**demos**]({charts_demo_host}/?app=plotly)
  15. - Use `pyecharts` to create Echarts-based charts in Python [**demos**]({charts_demo_host}/?app=pyecharts)
  16. - Use `pyg2plot` to create G2Plot-based charts in Python [**demos**]({charts_demo_host}/?app=pyg2plot)
  17. - Use `cutecharts.py` to create hand drawing style charts [**demos**]({charts_demo_host}/?app=cutecharts)
  18. **Screenshots**
  19. <a href="{charts_demo_host}/?app=bokeh">
  20. <img src="https://cdn.jsdelivr.net/gh/wang0618/pywebio-chart-gallery/assets/bokeh.png" alt="bokeh demo">
  21. </a>
  22. <a href="{charts_demo_host}/?app=plotly">
  23. <img src="https://cdn.jsdelivr.net/gh/wang0618/pywebio-chart-gallery/assets/plotly.png" alt="plotly demo">
  24. </a>
  25. <a href="{charts_demo_host}/?app=pyecharts">
  26. <img src="https://cdn.jsdelivr.net/gh/wang0618/pywebio-chart-gallery/assets/pyecharts.gif" alt="pyecharts demo">
  27. </a>
  28. <a href="{charts_demo_host}/?app=cutecharts">
  29. <img src="https://cdn.jsdelivr.net/gh/wang0618/pywebio-chart-gallery/assets/cutecharts.png" alt="cutecharts demo">
  30. </a>
  31. ### Links
  32. * PyWebIO Github [github.com/wang0618/PyWebIO](https://github.com/wang0618/PyWebIO)
  33. * Document [pywebio.readthedocs.io](https://pywebio.readthedocs.io)
  34. """.format(charts_demo_host=charts_demo_host)
  35. index_md_zh = r"""### 基本demo
  36. - [BMI计算](./bmi): 根据身高体重计算BMI指数
  37. - [聊天室](./chat_room): 和当前所有在线的人聊天 (不到90行代码实现)
  38. - [Markdown实时预览](./markdown_previewer): 可以实时预览的在线Markdown编辑器 (不到40行代码实现)
  39. - [在线五子棋游戏](./gomoku_game): 多人协作对战的五子棋游戏 (不到100行代码实现)
  40. - [输入演示](./input_usage): 演示PyWebIO输入模块的用法
  41. - [输出演示](./output_usage): 演示PyWebIO输出模块的用法
  42. - 更多Demo请见[文档](https://pywebio.readthedocs.io)中示例代码的在线Demo
  43. ### 数据可视化demo
  44. PyWebIO还支持使用第三方库进行数据可视化
  45. - 使用`bokeh`进行数据可视化 [**demos**]({charts_demo_host}/?app=bokeh)
  46. - 使用`plotly`进行数据可视化 [**demos**]({charts_demo_host}/?app=plotly)
  47. - 使用`pyecharts`创建基于Echarts的图表 [**demos**]({charts_demo_host}/?app=pyecharts)
  48. - 使用`pyg2plot`创建基于G2Plot的图表 [**demos**]({charts_demo_host}/?app=pyg2plot)
  49. - 使用`cutecharts.py`创建卡通风格图表 [**demos**]({charts_demo_host}/?app=cutecharts)
  50. **数据可视化demo截图**
  51. <a href="{charts_demo_host}/?app=bokeh">
  52. <img src="https://cdn.jsdelivr.net/gh/wang0618/pywebio-chart-gallery/assets/bokeh.png" alt="bokeh demo">
  53. </a>
  54. <a href="{charts_demo_host}/?app=plotly">
  55. <img src="https://cdn.jsdelivr.net/gh/wang0618/pywebio-chart-gallery/assets/plotly.png" alt="plotly demo">
  56. </a>
  57. <a href="{charts_demo_host}/?app=pyecharts">
  58. <img src="https://cdn.jsdelivr.net/gh/wang0618/pywebio-chart-gallery/assets/pyecharts.gif" alt="pyecharts demo">
  59. </a>
  60. <a href="{charts_demo_host}/?app=cutecharts">
  61. <img src="https://cdn.jsdelivr.net/gh/wang0618/pywebio-chart-gallery/assets/cutecharts.png" alt="cutecharts demo">
  62. </a>
  63. ### Links
  64. * PyWebIO Github [github.com/wang0618/PyWebIO](https://github.com/wang0618/PyWebIO)
  65. * 使用手册和实现文档见 [pywebio.readthedocs.io](https://pywebio.readthedocs.io/zh_CN/latest/)
  66. """.format(charts_demo_host=charts_demo_host)
  67. def main():
  68. """PyWebIO demos
  69. Basic demo and data visualization demo of PyWebIO.
  70. PyWebIO的基本demo和数据可视化demo
  71. """
  72. put_row([
  73. put_markdown('# PyWebIO demos'),
  74. put_html(
  75. '<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>')
  76. ], size='1fr auto').style('align-items:center')
  77. put_html('<script async defer src="https://buttons.github.io/buttons.js"></script>')
  78. if 'zh' in session_info.user_language:
  79. put_markdown(index_md_zh)
  80. else:
  81. put_markdown(index_md)