Skip to content

megatocha/cslaunch

Repository files navigation

CS Launch

English | Russian

A small utility for launching and monitoring CS2 via a web interface.

Release Download GitHub License GitHub Star GitHub Repo size Release Version

⚠️ Requirements

  • Python 3.8+ (3.11 recommended)
  • Dependencies from requirements.txt

🚀 Quick Start

Local Installation

# 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

⚙️ Configuration (.env)

# 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 production

Environment Variables

  • SECRET_KEY — Secret key for session encryption (required)
  • ADMIN_PASSWORD — Administrator password for /admin access (required)
  • HOST — Server host (default: 0.0.0.0)
  • PORT — Server port (default: 8000)
  • DEBUG — Debug mode (default: True, set to False in production)

🔗 Routes

Public Routes

  • GET /login — Login page (by access code or admin password)
  • POST /login — Login authentication
  • GET /logout — Logout

Protected Routes (Requires Authentication)

  • GET / — Main control panel
  • GET /get-status — Server status (JSON)
  • POST /start-cs2 — Start CS2 game
  • POST /stop-cs2 — Stop CS2 game

Admin Routes (Requires Admin Access)

  • GET /admin — Admin panel for code management
  • POST /admin/generate — Generate new access code
  • POST /admin/delete — Delete access code

📚 API Documentation

After starting the server:

📁 Project Structure

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

✨ Key Features

1. Modular Architecture

  • Separated routers (auth, admin, control)
  • Business logic in services
  • Clear separation of concerns

2. Pydantic Validation

  • Automatic input validation
  • Type-safe responses
  • Auto-generated documentation

3. Dependency Injection

  • Reusable authentication checks
  • Clean code without duplication
  • Easy testing

4. Services

  • DataService - JSON file operations
  • CodeService - Access code management
  • StatsService - Statistics tracking
  • CS2Service - Game process control

🔒 Security Features

  • Session-based authentication
  • Pydantic input validation
  • Admin-only routes protection
  • Secure password handling
  • HTTPS ready (configure reverse proxy)

🛠️ Development

# 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 .

🐛 Troubleshooting

Port already in use

# 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>

📝 License

This project is provided as-is for educational purposes.

🤝 Contributing

Contributions are welcome! Please feel free to submit pull requests.

📧 Support

For issues and questions, please open an issue on GitHub.


Made with ❤️ for CS2 community

About

A small utility for launching and monitoring CS2 via web interface.

Resources

License

Stars

Watchers

Forks

Packages

No packages published