https://github.com/codesignal/learn_pastebin-python
https://github.com/codesignal/learn_pastebin-python
Last synced: 7 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/codesignal/learn_pastebin-python
- Owner: CodeSignal
- License: other
- Created: 2025-09-02T15:41:55.000Z (7 months ago)
- Default Branch: main
- Last Pushed: 2025-09-04T11:37:31.000Z (7 months ago)
- Last Synced: 2025-09-04T13:25:16.061Z (7 months ago)
- Language: TypeScript
- Size: 35.6 MB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Pastebin Demo Application
A simple Pastebin-like application built with FastAPI, React, TypeScript. This application is intentionally built with minimal security measures for educational purposes in security courses.
## Features
- Code snippet creation and editing
- Support for multiple programming languages:
- TypeScript
- JavaScript
- Python
- Java
- C++
- Syntax highlighting using CodeMirror
- File upload functionality
- Basic user authentication
- Unique URLs for each saved snippet
- SQLite database with SQLAlchemy ORM
## ⚠️ Security Notice
This application is deliberately built WITHOUT security measures for educational purposes. It contains various vulnerabilities including but not limited to:
- SQL Injection possibilities
- No input validation
- Weak authentication
- No CSRF protection
- Potential XSS vulnerabilities
DO NOT USE THIS IN PRODUCTION!
## Prerequisites
- Python 3.10 (required for dependency compatibility)
- Node.js (v18 or higher)
- npm (Node Package Manager)
## Installation
1. Clone the repository:
```bash
git clone [repository-url]
cd python-learn_pastebin
```
2. Create and activate virtual environment:
```bash
# Create virtual environment
python3.10 -m venv venv
# Activate virtual environment
# On macOS/Linux:
source venv/bin/activate
# On Windows:
venv\Scripts\activate
```
3. Install Python dependencies:
```bash
pip install --upgrade pip
pip install -r requirements.txt
```
4. Install frontend dependencies and build:
```bash
cd frontend
npm install
npm run build
cd ..
```
5. Start the application:
```bash
python main.py
```
## Usage
1. Access the application at `http://localhost:3000`
2. Login with default credentials:
- Username: `admin`
- Password: `codesignal`
3. Create new snippets:
- Enter a title
- Select a programming language
- Write or paste your code
- Click "Save" to generate a unique URL
4. Upload files:
- Click the file upload button
- Select a text file
- The content will be automatically loaded into the editor
5. Access saved snippets:
- Use the generated URL (format: `/snippet/:id`)
- Edit and save changes as needed
## Development
### Running in Development Mode
```bash
# Ensure virtual environment is activated
source venv/bin/activate # On Windows: venv\Scripts\activate
# Run backend (will also serve frontend)
python main.py
```
The application runs on port 3000 by default.
### Troubleshooting
If you encounter issues:
1. **Python version issues**: Ensure you're using Python 3.8+
2. **Installing Python 3.11**:
- macOS: `brew install python@3.11`
- Ubuntu: `sudo apt install python3.11 python3.11-venv`
- Windows: Download from python.org
3. **Module not found errors**: Make sure virtual environment is activated and dependencies are installed
4. **Port already in use**: The app will try to use port 3000
5. **Database issues**: Delete `database.sqlite` file and restart
## API Endpoints
- `POST /api/auth/login` - User authentication
- `POST /api/auth/register` - User registration
- `POST /api/snippets` - Create/update snippets
- `GET /api/snippets/:id` - Retrieve a specific snippet
## Contributing
This is a demo application for educational purposes. If you find any bugs or want to suggest improvements, please open an issue or submit a pull request.