This Python script listens for a POST request at the endpoint /webhook
and then generates a ticket/label image using data from the Freshservice API. The generated image is send to woodleighschool/PrintService, which prints the sticker out.
- Python 3.11
- Flask
- Requests
- qrcode
- Pillow
- Clone the repository.
- Install the required packages using pip:
pip install -r requirements.txt
- Set environment variables
API_TOKEN
andFRESHSERVICE_API_KEY
. - Run the Flask application:
python main.py
The application should now be listening for POST requests at http://localhost:5000/webhook
.
Make a POST request to the /webhook
endpoint with the following JSON data:
{
"ticket_number": "123"
}
This will generate a ticket image for the ticket with ID 123
and print it out.
If the request contains an invalid ticket number or fails to connect to the printer, the error will be posted back, as {'status': 'Failed', 'reason': <reason>}
, else you will get {'status': 'Success'}
.
You can also put this application behind cloudflared, then use Freshservice's webhooks to sent tickets to be printed automatically.