This repository contains a simple Python webhook application using Flask and gunicorn. The application consumes a webhook, prints the body contents, a header attribute called x-uplift-signature-256, and an environment variable called SECRET_TOKEN to the terminal.
app.py: Contains the Flask application that defines the webhook route.wsgi.py: Contains the WSGI configuration and sets theSECRET_TOKENenvironment variable.utils.py: Utility functions for creating and verifying a HMAC signature for a JSON payload using a secret key.test.py: A test script to run the webhook application locally and send a test request.requirements.txt: A list of required Python packages for the application..gitignore: A list of files and directories that should be ignored by Git.
- Python 3.6 or higher
- pip (Python package manager)
- Clone the repository to your local machine.
git clone https://github.com/yourusername/uplift-sample-webhooks-python-app.git- Navigate to the project directory.
cd uplift-sample-webhooks-python-app- Create a virtual environment (optional, but recommended).
python -m venv venv- Activate the virtual environment.
- On Linux or macOS:
source venv/bin/activate- On Windows
venv\Scripts\activate- Install the required Python packages.
pip install -r requirements.txt
- Set the
SECRET_TOKENenvironment variable in thewsgi.pyfile.
os.environ['SECRET_TOKEN'] = 'replace_with_secret_token'Replace 'replace_with_secret_token' with your actual secret token value.
- Start the Flask development server.
python app.pyThe application will be running on http://localhost:5000.
- Open a new terminal window or tab, and make sure you're in the project directory.
- Run the test script.
python test.pyThe test script will start the Flask app, send a POST request to the /webhook/submit endpoint with a JSON payload and the x-uplift-signature-256 header, and then print the webhook body, header value, and environment variable to the terminal.
If the test is successful, the script will exit without any errors.
-
Log in to your GoDaddy cPanel account: Access your GoDaddy account and navigate to the cPanel dashboard.
-
Create a Python application environment: In the cPanel dashboard, look for the "Software" section and click on "Setup Python App". Choose the Python version you want to use, and then set the application root and the application URL. Click on "Create" to create the Python application environment.
-
Upload your application files: You can use an FTP client (like FileZilla) or the cPanel File Manager to upload your application files to the server. Make sure to upload the files to the application root directory you specified in step 2.
-
Install the required packages: In your cPanel Python application environment, you'll see a "Packages" section. Click on "Enter" and then input the package names and their respective versions (one at a time) that your application requires (e.g., Flask, gunicorn, requests). Click on "Install" to install each package.
-
Configure your application: In the cPanel Python application environment, you'll see a section called "App Configuration". Here, you should specify the entry point to your application. Set the "WSGI" field to the path of your WSGI file (e.g.,
app:appif your main file is namedapp.py). -
Set environment variables: In the "Environment Variables" section of the cPanel Python application environment, add any necessary environment variables (such as
SECRET_TOKEN). -
Restart your application: In the cPanel Python application environment, click on "Restart" to apply the changes and start your application.
-
Test your application: Access your application using the application URL you set in step 2. Check if the webhook functionality is working as expected.
Please note that specific steps may vary slightly depending on your cPanel version and configuration. If you encounter any issues or need further assistance, you can consult GoDaddy's help documentation or contact their support team.