-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathrun.py
51 lines (41 loc) · 1.9 KB
/
run.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import argparse
import re
from os import path
from bokeh_demo import bokehs
from cutecharts_demo import cutecharts
from plotly_demo import plotly_demo
from pyecharts_demo import pyecharts
from pyg2plot_demo import pyg2plot
from pywebio import start_server
from pywebio.output import put_markdown
from pywebio.session import info as session_info
readme_file = path.join(path.dirname(__file__), "README.md")
readme_zh_file = path.join(path.dirname(__file__), "README_zh.md")
readme = open(readme_file).read()
readme_zh = open(readme_zh_file).read()
async def index():
"""PyWebIO Chart Gallery
PyWebIO supports for data visualization with the third-party libraries. This page shows the demos of data visualization using plotly, bokeh, pyecharts and cutcharts in PyWebIO.
PyWebIO 支持使用第三方库进行数据可视化,本页面展示了在 PyWebIO 中使用plotly、bokeh、pyecharts和cutecharts进行数据可视化的示例
"""
global readme, readme_zh
md = readme_zh if 'zh' in session_info.user_language else readme
md = re.sub(r"\[\*\*demos\*\*\]\(.*?\?app=(.+?)\)", r"[**demos**](./?app=\g<1>)", md)
cdn = r"https://fastly.jsdelivr.net/gh/wang0618/pywebio-chart-gallery"
github_url = r"https://raw.githubusercontent.com/wang0618/pywebio-chart-gallery/master"
md = md.replace(github_url, cdn)
md = re.sub(r"<div></div>[\s\S]*$", "", md)
put_markdown(md)
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="PyWebIO Chart Gallery")
parser.add_argument('port', nargs='?', default=8080, help="run on the given port", type=int)
parser.add_argument('--debug', action="store_true")
args = parser.parse_args()
start_server({
'index': index,
'cutecharts': cutecharts,
'pyecharts': pyecharts,
'plotly': plotly_demo,
'bokeh': bokehs,
'pyg2plot': pyg2plot,
}, port=args.port, debug=args.debug)