A lightweight Flask microservice that generates chart images from matplotlib Python code. Designed as a companion service for claude-discord-bot.
一個輕量的 Flask 微服務,將 matplotlib Python 程式碼渲染成圖片,作為 claude-discord-bot 的配套服務使用。
- 📊 Executes matplotlib Python code and returns a PNG image
- 🔢 Renders LaTeX math formulas as images
- 🚀 Ready to deploy on Railway
| Component | Technology |
|---|---|
| Web framework | Flask |
| Chart rendering | matplotlib + numpy + scipy |
| Server | Gunicorn |
| Hosting | Railway |
Executes matplotlib Python code and returns a PNG image. 執行 matplotlib Python 程式碼並回傳 PNG 圖片。
Request body:
{
"code": "import matplotlib.pyplot as plt\nplt.plot([1,2,3],[4,5,6])"
}Response: PNG image (image/png)
Rules for the code / 程式碼規則:
- Must
importat the top - Do NOT call
plt.show() - Do NOT save files
Renders LaTeX math formulas as a PNG image. 將 LaTeX 數學公式渲染成 PNG 圖片。
Request body:
{
"formulas": ["E = mc^2", "\\frac{a}{b}"]
}Response: PNG image (image/png)
Health check — returns Chart service is running!
- Fork this repo
- Create a new project on Railway and connect the repo
- Railway will auto-detect the Python service and deploy it
- Copy the public URL and set it as
CHART_SERVICE_URLin your claude-discord-bot environment variables
pip install -r requirements.txt
python app.pyThe service will start on http://localhost:8000.
chart-service/
├── app.py # Main Flask app / 主程式
├── requirements.txt # Python dependencies
├── Procfile # Gunicorn start command
└── railway.toml # Railway deployment config
Pull requests are welcome! 歡迎送 PR!
MIT