Skip to content

shield44-project/pastebins

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Code Storage Website

A comprehensive web application for storing, viewing, categorizing, and executing code files. This platform supports multiple programming languages and allows you to run HTML websites within the application.

πŸŽ‰ Now with TypeScript and React support! The project includes a modern frontend built with TypeScript and React. See TYPESCRIPT_REACT_SETUP.md for details.

πŸ€– NEW: AI-Powered C/C++ Code Analysis! The platform now includes intelligent code analysis for C and C++ with security checks, best practices, and alternative implementations. See ENHANCED_COMPILER_README.md for details.

Features

πŸ“ Code Storage & Organization

  • Upload and store code files organized by language
  • Support for Python, Java, C, C++, and HTML
  • Add titles and descriptions to your code files
  • Automatic categorization by programming language

πŸ‘οΈ Code Viewing

  • Syntax-highlighted code editor (powered by CodeMirror)
  • Beautiful, modern UI with dark theme editor
  • View all your stored codes in organized categories

▢️ Code Execution

  • Execute Python, Java, C, and C++ code directly in the browser
  • Provide custom input (stdin) for interactive programs
  • View program output and error messages in real-time
  • Sandboxed execution with timeout limits for security
  • Enhanced C/C++ compiler with multiple standards support (C11, C++17, etc.)
  • Better error messages with helpful hints

πŸ€– AI Code Analysis (C/C++)

  • Intelligent static code analysis for C and C++ code
  • Security vulnerability detection (buffer overflows, format strings, etc.)
  • Memory leak detection and resource management suggestions
  • Best practices recommendations (const correctness, modern C++ features)
  • Alternative implementation suggestions (vectors vs arrays, smart pointers, etc.)
  • Complete refactored code examples - ChatGPT-style comprehensive code transformations
  • 🎯 Full refactored version combining all improvements into working code
  • Code quality improvements (magic numbers, uninitialized variables)
  • Real-time analysis with detailed, actionable feedback
  • πŸš€ One-click GitHub PR creation with refactored code
  • See ENHANCED_COMPILER_README.md for full documentation

🌐 HTML Website Preview

  • Upload complete HTML websites
  • View HTML code with syntax highlighting
  • Live preview of HTML websites running inside the platform
  • Fullscreen mode for better viewing experience
  • Copy code to clipboard
  • Refresh preview on demand

πŸ” Encrypted Code Storage

  • Server-side encrypted Python code examples
  • Hybrid RSA-4096 + AES-256-GCM encryption
  • Token-based authentication with HMAC-SHA256
  • View encrypted code files through secure web interface
  • Code is decrypted server-side only (private key never exposed)
  • Time-limited access tokens for enhanced security

πŸ“€ Multi-File Upload

  • Upload single files or multiple files at once
  • Support for folder/batch uploads
  • Automatic file organization by language
  • File preview before upload
  • Drag-and-drop support (coming soon)

☁️ Vercel Blob Storage Integration

  • Persistent file storage for serverless deployments
  • Automatic file synchronization to Vercel Blob
  • Files persist across deployments on Vercel
  • Graceful fallback to local storage
  • Works alongside GitHub integration
  • See VERCEL_BLOB_SETUP.md for setup guide

πŸ“ Notes with Screenshots

  • Create and store notes with rich text content
  • Attach multiple screenshots/images to notes
  • Server-side storage with Vercel KV (Redis-compatible database)
  • Drag-and-drop image upload support
  • Image gallery with thumbnail previews
  • Edit and delete notes
  • Fallback to local memory if KV not configured
  • Accessible from any code view page via "πŸ“ Notes" button
  • See VERCEL_KV_SETUP.md for setup guide
  • Perfect for documentation, reminders, and visual references

Supported Languages

Language Extension Execution Support Compilation AI Analysis
Python .py βœ… Yes No ⏳ Coming Soon
Java .java βœ… Yes Yes (javac) ⏳ Coming Soon
C .c βœ… Yes Yes (gcc/clang) βœ… Yes
C++ .cpp βœ… Yes Yes (g++/clang++) βœ… Yes
HTML .html 🌐 Live Preview N/A N/A

GitHub Pages Deployment

🌐 Live Demo

Visit the live demo at: https://shield44-project.github.io/codes_storer_website/

The GitHub Pages deployment includes:

  • A landing page explaining the project and features
  • The encrypted file viewer (viewer.html) as a standalone static page

⚠️ Important Limitations

This is primarily a Flask application that requires a Python backend server. GitHub Pages only supports static HTML/CSS/JavaScript files and cannot run the full application with the following features:

  • Code execution (Python, Java, C, C++)
  • Code storage and upload
  • File management

To use these features, you must run the application locally (see installation instructions below).

What Works on GitHub Pages

  • βœ… Project landing page with documentation
  • βœ… Encrypted file viewer (requires separate decryption server)
  • βœ… Static content and documentation

Installation (Local Deployment)

Prerequisites

  • Python 3.8 or higher
  • For code execution support, install:
    • Python 3 (for Python code execution)
    • Java JDK (for Java code execution)
    • GCC (for C code execution)
    • G++ (for C++ code execution)

Setup Instructions

  1. Clone the repository:
git clone https://github.com/shield44-project/codes_storer_website.git
cd codes_storer_website
  1. Install Python dependencies:
pip install -r requirements.txt
  1. Run the Flask application:
python app.py
  1. Open your browser and navigate to:
http://localhost:5000

Running with Virtual Environment (Recommended)

# Create virtual environment
python -m venv venv

# Activate virtual environment
# On Windows:
venv\Scripts\activate
# On macOS/Linux:
source venv/bin/activate

# Install dependencies
pip install -r requirements.txt

# Run the application
python app.py

Configuration

The application can be configured using environment variables:

Storage Configuration

CODES_DIRECTORY (optional)

  • Directory for storing code files
  • Default: stored_codes
  • Example: /tmp/stored_codes (for serverless platforms)

shield44_READ_WRITE_TOKEN (optional, recommended for Vercel)

  • Vercel Blob Storage read-write token for persistent storage
  • Enables file persistence on serverless platforms
  • See VERCEL_BLOB_SETUP.md for setup
  • Example: vercel_blob_rw_GmsSyO1ENI6nA5GJ_ETd7tIhY7RialiPNyz5YaP8U2EZTAZ

GitHub Integration (optional)

GITHUB_TOKEN

GITHUB_REPO

  • Target repository for commits
  • Default: shield44-project/pastebins

GITHUB_BRANCH

  • Target branch for commits
  • Default: main

Flask Configuration

FLASK_DEBUG

  • Enable debug mode (True/False)
  • Default: False (production)

FLASK_HOST

  • Server host
  • Default: 0.0.0.0

FLASK_PORT

  • Server port
  • Default: 5000

Usage Guide

Uploading Code

Single File Upload (Paste Code):

  1. Click on "Upload New Code" button on the home page
  2. Select the "πŸ“ Paste Code" tab
  3. Select the language (Python, Java, C, C++, or HTML)
  4. Enter a title for your code
  5. Optionally add a description
  6. Paste your code in the code editor
  7. Click "Upload Code"

Multiple File Upload:

  1. Click on "Upload New Code" button on the home page
  2. Select the "πŸ“ Upload Files" tab
  3. Select the language
  4. Click "Select Files" and choose one or more files
  5. Preview the selected files
  6. Click "Upload Files"

Viewing Encrypted Python Code Examples

The repository includes encrypted Python code examples that can be viewed securely:

  1. Setup (First Time Only):

    • Place your private_key.pem in the root directory OR
    • Run python setup_encryption.py for guided setup
    • See SETUP_ENCRYPTION.md for detailed instructions
  2. Viewing Files:

    • Navigate to /encrypted-viewer on the running Flask app
    • Click on any Python file from the list
    • Files are automatically decrypted and displayed (no manual token entry needed!)

Note: The system uses "shield44" as the default token secret for generating access tokens. The private key (private_key.pem) must be present for decryption to work. See SETUP_ENCRYPTION.md for more details.

Viewing and Executing Code

For Programming Languages (Python, Java, C, C++):

  1. Navigate to a language category from the home page
  2. Click on a code file to view it
  3. Click "▢️ Run Code" to execute the code
  4. Optionally provide input in the "Input (stdin)" field
  5. View the output in the output panel

For HTML Websites:

  1. Navigate to the HTML category
  2. Click on an HTML file to view it
  3. The left panel shows the HTML code
  4. The right panel shows a live preview of the website running
  5. Use the "πŸ”„ Refresh" button to reload the preview
  6. Use the "β›Ά Fullscreen" button to view the website in fullscreen mode
  7. Use the "πŸ“‹ Copy Code" button to copy the HTML code

Category Management

All uploaded files are automatically organized by language:

  • Python files β†’ Python category
  • Java files β†’ Java category
  • C files β†’ C category
  • C++ files β†’ C++ category
  • HTML files β†’ HTML category

Project Structure

codes_storer_website/
β”œβ”€β”€ app.py                  # Main Flask application (with encryption support)
β”œβ”€β”€ config.py              # Configuration settings
β”œβ”€β”€ encrypt_files.py       # Tool for encrypting Python files
β”œβ”€β”€ decrypt_server.py      # Standalone decryption server
β”œβ”€β”€ generate_keys.py       # RSA key generation tool
β”œβ”€β”€ token_gen.py           # Access token generation tool
β”œβ”€β”€ requirements.txt       # Python dependencies
β”œβ”€β”€ README.md              # This file
β”œβ”€β”€ ENCRYPTION_README.md   # Encryption documentation
β”œβ”€β”€ .gitignore            # Git ignore rules
β”œβ”€β”€ public_key.pem        # RSA public key (committed)
β”œβ”€β”€ private_key.pem       # RSA private key (NOT committed, server-only)
β”œβ”€β”€ viewer.html           # Encrypted file viewer (standalone page)
β”œβ”€β”€ templates/            # HTML templates
β”‚   β”œβ”€β”€ base.html         # Base template
β”‚   β”œβ”€β”€ index.html        # Home page
β”‚   β”œβ”€β”€ category.html     # Category listing page
β”‚   β”œβ”€β”€ upload.html       # Upload form (with multi-file support)
β”‚   β”œβ”€β”€ view_code.html    # Code viewer for executable languages
β”‚   └── view_html.html    # HTML website viewer with live preview
β”œβ”€β”€ static/               # Static assets
β”‚   └── css/
β”‚       └── style.css     # Stylesheet
β”œβ”€β”€ encrypted/            # Encrypted Python code examples (committed)
β”‚   β”œβ”€β”€ manifest.json     # Index of encrypted files
β”‚   └── *.py.enc.json    # Encrypted Python files
└── stored_codes/         # Storage directory (auto-created, not committed)
    β”œβ”€β”€ python/           # Python files
    β”œβ”€β”€ java/             # Java files
    β”œβ”€β”€ c/                # C files
    β”œβ”€β”€ cpp/              # C++ files
    β”œβ”€β”€ html/             # HTML files
    └── *_metadata.json   # Metadata files

Security Features

Code Execution Security

  • Code execution is sandboxed with 5-second timeout limits
  • Temporary directory usage for compilation and execution
  • Input sanitization for uploaded code
  • HTML preview uses iframe with sandbox attributes
  • No direct file system access from executed code
  • Command injection prevention with shell=False

Encrypted Code Storage

  • Hybrid RSA-4096 + AES-256-GCM encryption for Python code examples
  • Server-side decryption only - private key never exposed to clients
  • Token-based authentication with HMAC-SHA256 signatures
  • Time-limited access tokens (default 1 hour, configurable)
  • Encrypted files stored in repository, safe to commit
  • Private key must be kept secure on server (excluded from git)
  • See ENCRYPTION_README.md for detailed documentation

File Upload Security

  • File size limits (16MB max)
  • File extension validation
  • Filename sanitization to prevent path traversal
  • Content-type validation

Technologies Used

Backend

  • Flask: Python web framework
  • Python 3: Core backend language
  • Cryptography: RSA-OAEP, AES-GCM encryption
  • HMAC-SHA256: Token-based authentication

Frontend

  • TypeScript: Type-safe JavaScript development
  • React: Component-based UI framework
  • Webpack: Module bundler and build tool
  • HTML5, CSS3: Modern web standards
  • JavaScript (ES6+): Modern JavaScript features

Development Tools

  • Node.js & npm: Package management
  • ts-loader: TypeScript compilation for Webpack
  • CodeMirror: Syntax highlighting

Code Execution

  • subprocess: Python code execution
  • Compilers: javac (Java), gcc (C), g++ (C++)

Frontend Development

This project now includes a modern TypeScript/React frontend. For detailed information about the frontend setup, see TYPESCRIPT_REACT_SETUP.md.

Quick Start (Frontend)

# Install dependencies
npm install

# Start development server
npm start

# Build for production
npm run build

The React app runs on http://localhost:3000 during development, while the Flask backend runs on http://localhost:5000.

Browser Compatibility

  • Chrome/Edge (recommended)
  • Firefox
  • Safari
  • Opera

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is open source and available under the MIT License.

Troubleshooting

Code execution not working?

  • Ensure the required compiler/interpreter is installed
  • Check that the PATH environment variable includes the compiler/interpreter

HTML preview not showing?

  • Check browser console for errors
  • Ensure the HTML file is valid
  • Try the refresh button

Upload failing?

  • Check that the code syntax is valid
  • Ensure title doesn't contain special characters
  • Verify the file extension matches the selected language

AI Analysis not showing results?

  • Ensure you're viewing a C or C++ file
  • Check browser console for errors
  • Try refreshing the page
  • See ENHANCED_COMPILER_README.md for troubleshooting

Enhanced compiler errors?

  • Install required compilers: sudo apt-get install gcc g++ clang
  • System will automatically fall back to online compilation
  • Check ENHANCED_COMPILER_README.md for details

Future Enhancements

  • βœ… AI Code Analysis for C/C++ (Completed!)
  • βœ… Enhanced C/C++ Compiler with Multiple Standards (Completed!)
  • AI Code Analysis for Python, Java, and other languages
  • Support for more languages (JavaScript, Ruby, Go, Rust, etc.)
  • Machine learning-based bug prediction
  • Collaborative code editing
  • Code sharing via links
  • Syntax checking before upload
  • Code version history
  • Search functionality
  • Code comments and annotations
  • Real-time code analysis as you type
  • Integration with popular IDEs (VS Code, Vim, etc.)

Support

For issues, questions, or suggestions, please open an issue on GitHub.

About

A simple code storing platform to easily view its output and its code simultaneously

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •