This is a Flask-based backend that generates certificates from a template image, custom font, and CSV data. The output is a downloadable ZIP archive containing the generated certificates in image format.
- Upload template image
- Upload font file (.ttf)
- Upload CSV file with recipient data
- Define multiple dynamic text fields with custom positions and sizes
- Specify text color in HEX format
- Returns all certificates as a ZIP archive
- Supports CORS for frontend integration
git clone https://github.com/yourusername/certificate-generator-backend.git
cd certificate-generator-backendpip install -r requirements.txtUsing Flask:
flask run --port=8030Using Gunicorn (for production):
gunicorn -w 1 -b 0.0.0.0:8030 app:appAccepts a multipart/form-data request with the following fields:
| Field | Type | Required | Description |
|---|---|---|---|
| template | File (.png/.jpg) | Yes | The certificate background image |
| font | File (.ttf) | Yes | The font file used for rendering text |
| csv | File (.csv) | Yes | CSV file with column headers matching field names |
| fields | JSON string | Yes | List of field definitions with coordinates |
| color | String (hex) | Yes | Text color in HEX format (e.g., #000000) |
[
{ "name": "Name", "x": 200, "y": 300, "size": 40 },
{ "name": "Course", "x": 200, "y": 400, "size": 30 }
]curl -X POST http://localhost:8030/generate \
-F "template=@template.png" \
-F "font=@Poppins-Regular.ttf" \
-F "csv=@participants.csv" \
-F "fields=$(cat fields.json)" \
-F "color=#000000" \
--output certificates.zipThe server is CORS-enabled using Flask-CORS to allow frontend integration from different origins.
- Python
- Flask
- Pillow (PIL)
- Flask-CORS
- Gunicorn (optional)
MIT License