Skip to content

nikita-popov/pystorage

Repository files navigation

PyStorage

Pretty simple selfhosted file storage solution with web interface and REST API.

Perfect for home use and small teams.

Interface

Features

  • User authentication
  • File upload via web interface or API
  • Isolated storage per user
  • Docker support
  • 90%+ test coverage
  • REST API for integration
  • Easy deployment

Quick Start

Installation

  • Clone repository:
git clone https://github.com/nikita-popov/pystorage.git
cd pystorage

Configuration

  • Copy config template:
cp example.config.py config.py
  • Configure settings in config.py:
class Config:
    SECRET_KEY = 'your-secret-key'  # Generate with: openssl rand -hex 32
    USERS = {
        'admin': 'pbkdf2:sha256...',  # Use generate_password_hash
    }
  • Password generation:
python -c "from werkzeug.security import generate_password_hash; print(generate_password_hash('my_strong_password'))"

Running

With docker

docker compose up -d

With gunicorn

  • Create a virtualenv and install dependencies:
python3 -m venv .venv
source venv/bin/activate
pip install --upgrade pip
pip install -r requirements.txt
  • Start app:
gunicorn --workers 4 --bind 0.0.0.0:5000 wsgi-app:app

Usage

Web Interface:

  • Open http://localhost:5000
  • Login with your credentials
  • Upload and manage files through intuitive interface

API

You can also use it with CLI utils like curl.

Base URL

http://localhost:5000/api/

Endpoints

Method Path Description
GET /files List files
POST /upload Upload file
GET /download/:id Download file
DELETE /delete/:id Delete file

Example Request:

# Upload file
curl -u user:pass -F "[email protected]" http://localhost:5000/api/upload

# List files
curl -u user:pass http://localhost:5000/api/files

Example Response:

{
  "files": [
    {
      "name": "report.pdf",
      "size": 24576,
      "url": "http://localhost:5000/api/download/report.pdf"
    }
  ]
}

Testing

Run with coverage report:

pytest

License

MIT License - see LICENSE for details.

About

Pretty simple file storage

Topics

Resources

License

Stars

Watchers

Forks