A Flask web application that transforms strings based on predefined patterns with access control and administrative features.
The String Transformer application allows users to submit strings and receive transformed versions based on predefined patterns. Key features include:
- One-Time Access: Once a transformed string has been viewed, it cannot be accessed again
- IP-Based Restrictions: Prevents multiple views from the same IP address
- Admin Dashboard: Manage string patterns, users, and view access logs
- Blueprint Architecture: Modular code structure for better maintainability
- Proxy Support: Properly handles real client IP addresses when behind proxies like Nginx
- Maintenance Utilities: Integrated tools for maintenance and troubleshooting
- Mobile Support: Dedicated mobile interface with optimized user experience
- Python 3.6+
- pip (Python package manager)
- Git (optional)
-
Clone the repository or download the source code:
git clone https://github.com/huythedev/game_8-3.git cd game_8-3
-
Create a virtual environment:
python -m venv venv
or
python3 -m venv venv
-
Activate the virtual environment:
- Windows:
venv\Scripts\activate
- Linux/macOS:
source venv/bin/activate
- Windows:
-
Install the required packages:
pip install -r requirements.txt
or
pip3 install -r requirements.txt
-
Create a
.env
file from the template:cp .env.example .env
-
Edit the
.env
file to configure your installation. -
Run the application:
python app.py
or
python3 app.py
Configuration is managed through environment variables, which can be set in a .env
file:
Variable | Description | Default |
---|---|---|
SECRET_KEY | Flask secret key for session security | Random generated |
DATABASE_URI | SQLAlchemy database URI | sqlite:///strings.db |
SECURE_COOKIES | Enable secure cookies | True |
HOST | Host address to bind | 127.0.0.1 |
PORT | Port number | 8000 |
DEBUG | Flask debug mode | False |
BEHIND_PROXY | Whether app is behind a proxy | False |
After installation, you can access the admin interface at /admin/login
with these default credentials:
- Username: admin
- Password: 123
Important: Change this password immediately after first login!
The application includes a comprehensive maintenance utility that can help fix common issues:
python maintenance.py
This provides a menu-driven interface for:
- Resetting the database
- Fixing database issues
- Fixing route issues
- Checking critical templates
- Performing a quick fix of all systems
python -m waitress --host=0.0.0.0 --port=8000 wsgi:application
or
python3 -m waitress --host=0.0.0.0 --port=8000 wsgi:application
When using Nginx as a reverse proxy, ensure you have the correct configuration to forward client IP addresses:
location / {
proxy_pass http://127.0.0.1:8000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
Also, set BEHIND_PROXY=True
in your .env
file.
- Database Errors: Run the maintenance utility and choose "Fix Database Issues" or "Reset Database" option.
- Permission Denied: Ensure the directory has proper write permissions for log files.
- Missing Templates: Use the "Fix Critical Templates" option in the maintenance menu.
- Route Issues: Select "Fix Route Issues" from the maintenance menu.
Always use a virtual environment for development:
python -m venv venv
source venv/bin/activate # Linux/macOS
venv\Scripts\activate # Windows
pip install -r requirements-dev.txt
pytest
This project is licensed under the MIT License - see the LICENSE file for details.
- The application restricts access to transformed strings based on IP addresses.
- Admin pages require authentication.
- Be cautious about exposing the application directly to the internet without proper security measures.
- Consider changing the default admin password immediately after installation.
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request