Skip to content

Carpathian-LLC/deployment-example-flask

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Carpathian Flask Test Application

A minimal Flask application for testing deployments and API endpoints.

Overview

This application provides test endpoints to verify that your deployment is working correctly. It includes health check endpoints, API key authentication, and automatic configuration setup.

Quick Start

1. Install Dependencies

pip install -r requirements.txt

2. Run the Application

python run.py

3. Access the Application

Open your browser to: http://localhost:3005

Available Endpoints

GET /health

Returns a healthy status response (200).

curl http://localhost:3005/health

GET /unhealthy

Returns an unhealthy status response (503) for testing failure scenarios.

curl http://localhost:3005/unhealthy

GET /api/protected

Requires API key authentication. Returns "protected" data when valid credentials are provided.

curl -H "Authorization: Bearer YOUR_API_KEY" http://localhost:3005/api/protected

GET /api/endpoints

Returns a JSON list of all available endpoints with documentation.

curl http://localhost:3005/api/endpoints

GET /info

Returns deployment and server information.

curl http://localhost:3005/info

Configuration

Environment Variables

The application auto-generates a .env file on first run with default test values. For production use, update these values:

API_KEY=your_production_api_key_here
SECRET_KEY=your_secret_key_here
ENVIRONMENT=production
COMMIT_SHA=your_commit_hash
BRANCH=your_branch_name

Generate Secure Keys

python -c "import secrets; print('carpathian_prod_' + secrets.token_hex(32))"

Project Structure

deployment-example-flask/
├── src/
│   └── app.py           # Main application code
├── run.py               # Application entry point
├── requirements.txt     # Python dependencies
├── .env                 # Environment configuration (auto-generated)
├── .env.example         # Environment template
└── .gitignore          # Git ignore rules

API Authentication

Protected endpoints require an API key in the request header:

Option 1: Bearer Token

Authorization: Bearer YOUR_API_KEY

Option 2: API Key Header

X-API-Key: YOUR_API_KEY

Your API key is located in the .env file after first run.

Deployment

GitHub Actions

Push your code to trigger automated deployment via the included workflow.

Manual Deployment

Set environment variables on your deployment platform:

  • API_KEY: Your production API key
  • COMMIT_SHA: Current commit hash
  • BRANCH: Current branch name
  • ENVIRONMENT: production

The application uses Gunicorn for production serving.

Development

Change Port

Edit run.py and modify the port parameter:

app.run(host='0.0.0.0', port=YOUR_PORT, debug=False)

Edit Application Code

All application logic is in src/app.py.

Troubleshooting

Import Errors

pip install -r requirements.txt

Port Already in Use Change the port in run.py or stop the process using port 3005.

Missing .env File The application creates this automatically on first run. If deleted, restart the application.

Documentation


Developed by Carpathian, LLC

About

A minimal Flask application demonstrating automated deployments with Carpathian Cloud and GitHub Actions.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages