BoBkiNN / PySimpleHost

Simple python flask server for hosting folder contents

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Simple python flask server for hosting folder contents

Features:

  • Basic auth (username and password)
  • Uploading and downloading files
  • HTML view of repo (with dark theme)
  • Multi-folder serving

Config explanation:

{
    "host": "0.0.0.0", // host ip
    "port": 9800, // port
    "user": "admin", // username 
    "password": "test123", // password
    "protect": [ // what features are protected using password. Defaults to ["put"]
        "put" // list of "put", "get", "index", "all"
    ],
    "show-mtime": true, // send file modify time in index?
    "show-size": true, // send file size in index?
    "display": { // settings of web index page
        "col1-spacing": 51, // size of first column
        "col2-spacing": 20, // size of second column
        "humanize-size": true, // if false, writes size in bytes
        "gnu-style-size": true, // if true, writes B, KB, MB and etc, else Bytes, KiB, MiB and etc
        "auto-dark-theme": true // if true, css for auto dark theme is added
    },
    "contents": { // what folders/files to serve
        "": "./www", // base path will show us content from ~/www folder
        "repo":"~/.m2/repository/" // "/repo" url with show us maven repository
    },
    "redirect-flow": { // where to omit content
        "": "index.html" // show "/index.html" if url path is empty
    },
    "watchdog": true // should we track changes in config.json?
}

Protect values description:

  • put - require auth when uploading files
  • get - require auth when getting files
  • index - require auth when accesing list of files
  • all - combine of upper three values

Installing

  1. Clone repository git clone https://github.com/BoBkiNN/PySimpleHost
  2. Install python >3.9
  3. Install required modules: python -m pip install -r requirements.txt
  4. Configure config.json inside cloned repository

Running:

  • waitress:
    1. Install waitress module: python -m pip install waitress
    2. python -m waitress --call --listen *:9800 main:start
  • not production: python main.py

About

Simple python flask server for hosting folder contents


Languages

Language:Python 100.0%