Skip to content

venkatranabothu/sample-python-app

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Sample Django Web Application

A simple Django web application for benchmarking and testing purposes, using Django's built-in development server.

Features

  • Django Framework: Clean, maintainable Python web framework
  • Built-in Server: Uses Django's development server for simplicity
  • Health Check: Built-in health monitoring endpoint
  • REST API: Clean API endpoints with Django views
  • JSON Responses: Structured JSON responses for all endpoints
  • Database Ready: SQLite database with Django ORM
  • Static Files: WhiteNoise for efficient static file serving

Architecture

  • Framework: Django 4.2.7 (Python web framework)
  • Server: Django's built-in development server
  • Database: SQLite with Django ORM
  • Static Files: WhiteNoise middleware

Endpoints

  • GET / - Welcome message with application info and endpoint list
  • GET /health - Health check endpoint
  • GET /api/users - Sample users data
  • GET /api/stats - Server statistics and performance metrics
  • POST /api/echo - Echo back request data
  • GET /api/echo - Echo endpoint information

Running Locally

pip install -r requirements.txt
python app.py

The server will start on port 8000 (or PORT environment variable).

Environment Variables

  • PORT - Server port (default: 8000)
  • DEBUG - Enable Django debug mode (default: false)
  • SECRET_KEY - Django secret key for production

Deployment

This application is designed for deployment on:

  • DigitalOcean App Platform
  • Heroku
  • AWS ECS/Fargate
  • Google Cloud Run
  • Any container platform supporting Python/Django

High-performance Django app for load testing

Running with Gunicorn

To support high RPS, run the app using gunicorn:

pip install -r requirements.txt
cd sample-python-app
export DJANGO_SETTINGS_MODULE=sampleproject.settings
# Example: 8 workers, 16 threads each
gunicorn app:application --workers 8 --threads 16 --bind 0.0.0.0:8000

Adjust workers/threads for your CPU. Gunicorn provides robust concurrency for load testing.

API Examples

Health Check

curl http://localhost:8000/health

Get Users

curl http://localhost:8000/api/users

Server Stats

curl http://localhost:8000/api/stats

Echo Data

curl -X POST http://localhost:8000/api/echo \
  -H "Content-Type: application/json" \
  -d '{"message": "Hello Django!"}'

Development

The application uses Django's built-in development server, which automatically:

  • Handles database migrations on startup
  • Serves static files
  • Provides detailed error pages in debug mode
  • Auto-reloads on code changes (in development mode)

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages