- Python 3.8+ (3.11 recommended)
- Dependencies from
requirements.txt
# 1. Create virtual environment
python -m venv venv
venv\Scripts\activate # Windows
source venv/bin/activate # Linux/Mac
# 2. Copy environment example
copy example.env .env # Windows
cp example.env .env # Linux/Mac
# 3. Install dependencies
pip install -r requirements.txt
# 4. Run application
python main.py
# or
uvicorn main:app --reload --host 0.0.0.0 --port 8000
# Access at http://localhost:8000# Security (REQUIRED)
SECRET_KEY=your-super-secret-key-change-this
ADMIN_PASSWORD=your-admin-password
# Server Configuration
HOST=0.0.0.0
PORT=8000
DEBUG=True # Set to False in productionSECRET_KEY— Secret key for session encryption (required)ADMIN_PASSWORD— Administrator password for/adminaccess (required)HOST— Server host (default: 0.0.0.0)PORT— Server port (default: 8000)DEBUG— Debug mode (default: True, set to False in production)
GET /login— Login page (by access code or admin password)POST /login— Login authenticationGET /logout— Logout
GET /— Main control panelGET /get-status— Server status (JSON)POST /start-cs2— Start CS2 gamePOST /stop-cs2— Stop CS2 game
GET /admin— Admin panel for code managementPOST /admin/generate— Generate new access codePOST /admin/delete— Delete access code
After starting the server:
- Swagger UI: http://localhost:4242/docs
- ReDoc: http://localhost:4242/redoc
cslaunch/
│
├── app/
│ ├── __init__.py
│ ├── config.py # Application configuration
│ ├── models.py # Pydantic models
│ ├── services.py # Business logic
│ ├── dependencies.py # FastAPI dependencies
│ │
│ └── routers/
│ ├── __init__.py
│ ├── auth.py # Authentication
│ ├── admin.py # Admin panel
│ └── control.py # CS2 control
│
├── templates/
│ ├── index.html # Main page
│ ├── login.html # Login page
│ └── admin.html # Admin panel
│
├── static/
│ ├── style.css # Styles
│ └── script.js # Frontend logic
│
├── data/ # Created automatically
│ ├── stats.json # Statistics
│ └── codes.json # Access codes
│
├── main.py # Application entry point
├── requirements.txt # Python dependencies
├── .dockerignore # Docker ignore file
├── example.env # Environment example
└── README.md # This file
- Separated routers (auth, admin, control)
- Business logic in services
- Clear separation of concerns
- Automatic input validation
- Type-safe responses
- Auto-generated documentation
- Reusable authentication checks
- Clean code without duplication
- Easy testing
DataService- JSON file operationsCodeService- Access code managementStatsService- Statistics trackingCS2Service- Game process control
- Session-based authentication
- Pydantic input validation
- Admin-only routes protection
- Secure password handling
- HTTPS ready (configure reverse proxy)
# Install dev dependencies
pip install -r requirements.txt
# Run with auto-reload
uvicorn main:app --reload
# Run tests (if available)
pytest
# Format code
black .
isort .
# Type checking
mypy .# Change PORT in .env file
PORT=6969
# Or stop conflicting service
# Windows
netstat -ano | findstr :8000
taskkill /PID <PID> /F
# Linux
sudo lsof -i :8000
kill -9 <PID>This project is provided as-is for educational purposes.
Contributions are welcome! Please feel free to submit pull requests.
For issues and questions, please open an issue on GitHub.
Made with ❤️ for CS2 community