Skip to content

CodeSignal/learn_pastebin-python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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:
git clone [repository-url]
cd python-learn_pastebin
  1. Create and activate virtual environment:
# Create virtual environment
python3.10 -m venv venv

# Activate virtual environment
# On macOS/Linux:
source venv/bin/activate
# On Windows:
venv\Scripts\activate
  1. Install Python dependencies:
pip install --upgrade pip
pip install -r requirements.txt
  1. Install frontend dependencies and build:
cd frontend
npm install
npm run build
cd ..
  1. Start the application:
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

# 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 [email protected]
    • 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.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published