Spaces:
Runtime error
Runtime error
Download widgets/utils.py from Adapting/TrendFlow: direct link, hf CLI and curl.
- Browser
- Download file 527 Bytes
-
https://huggingface.co/spaces/Adapting/TrendFlow/resolve/247c4e3a310aede4e2b36bd1dd2ebf7ee614011c/widgets/utils.py
- Command line
-
hf download hf://spaces/Adapting/TrendFlow@247c4e3a310aede4e2b36bd1dd2ebf7ee614011c/widgets/utils.py
-
curl -L -o utils.py https://huggingface.co/spaces/Adapting/TrendFlow/resolve/247c4e3a310aede4e2b36bd1dd2ebf7ee614011c/widgets/utils.py
527 Bytes
| from pathlib import Path | |
| import os | |
| PACKAGE_ROOT = str(Path(__package__).absolute()) | |
| def readfile(path:str) -> str: | |
| with open(path) as f: | |
| ret = f.read() | |
| return ret | |
| def generate_html_pyecharts(chart, file_name) -> str: | |
| if chart.render is None: | |
| raise RuntimeError('Please pass a PyEchart chart object!') | |
| path = f'./templates/{file_name}' | |
| chart.render(path) | |
| html = readfile(path).replace('<body>','<center><body>').replace('</body>','</body></center>') | |
| os.remove(path) | |
| return html | |