Package: pycbox
Simple web interface showing a directory-listing or thumbnail-gallery of the
files or images in thefiles/subdirectory. Users can upload files if the
folder has write-permissions for all.An example can be seen atpix.coldfix.eu.This repo is a python rewrite of thepicboxphp app.UsageYou can quickly install the latest release and locally serve files from your~/Picturesdirectory as follows:pipinstallpycbox--userpycbox-w~/PicturesIn order to allow network access on all network interfaces you also need to
add the--host0.0.0.0option, e.g.:pycbox-w~/Pictures-h0.0.0.0Alternatively, you can run pycbox without installation from the git checkout.
Though in this case, you still need to install the dependencies as follows:pipinstall-rrequirements.txt--user./bin/pycbox-w~/PicturesHowever, running the pycbox from the command line like this is not recommended
for deployment! From theflask documentation:While lightweight and easy to use, Flask’s built-in server is not suitable
for production as it doesn’t scale well and by default serves only one
request at a time. Some of the options available for properly running
Flask in production are documented here.A more sophisticated server can e.g. be run using twisted:twistd--nodaemon--logfile=-web--port=tcp:5000--wsgi=pycbox.appIn fact, the recommended method is using docker, seeDeployment.ConfigIf it exists,config.ymlwill be loaded from the active directory. The
config file may become mandatory, so you should always copy and adjust the
shipped example config:cpconfig.example.ymlconfig.ymlAn alternate config file name or path can be specified via thePYCBOX_CONFIGenvironment variable, i.e. like this:PYCBOX_CONFIG=/path/to/alt_config.ymlpythonpycbox.pyPYCBOX_CONFIG=/path/to/alt_config.ymltwistdweb--wsgi=pycbox.appDeploymentThe recommended method is to run pycbox is via docker. The image can be built
and run as follows:dockerbuild.-tpycboxdockerrun--cap-drop=all\-v`pwd`/files:/pycbox/files\-p5000:5000\--name=pycboxpycboxor simply:docker-composeupAdd-dto either command line to run in the background.ProxyIn order to run the application on a subdomain, you will need to setup a proxy
forward. Examplenginxconfiguration to show the site onpixsubdomain:server{listen80;listen[::]:80;server_namepix.example.compix.example.org;return301https://$host$request_uri;}server{listen443ssl;listen[::]:443ssl;server_namepix.example.compix.example.org;access_log/var/log/nginx/access_pics.log;location/{proxy_passhttp://localhost:5000;proxy_set_headerX-Real-IP$remote_addr;proxy_set_headerHost$host;proxy_set_headerX-Forwarded-For$proxy_add_x_forwarded_for;proxy_set_headerUpgrade$http_upgrade;proxy_set_headerConnectionupgrade;}}UploadTo enable uploading to a particular subfolder, make it writable by all:mkdir-pfiles/publicchmod777files/publicDebug modeDO NOT DO THIS IN PRODUCTIONsince it allows the client to execute
arbitrary code.To run the application in debug mode on port 5000, type either:pythonpycbox.py--debugor (recommended):FLASK_APP=pycbox.pyFLASK_DEBUG=1flaskrunThe second command takes care of reloading the server when the python module
is changed and is therefore recommended for development.Big TODOsuse redis for caching thumbs and highlighted filesuse asciidoc for markdownuse pygments for highlightingconfigure via YAML file: auth, quota, uploads, deny globsChanges0.0.3Date: 06.09.2017fix startup error in debug mode, due to port being a stringfix startup error in docker container, due to permissionsfix error when trying to upload into root folderfix permission problems in docker container0.0.2Date: 11.08.2017fix install package (if installing using pip)0.0.1Date: 10.08.2017Features include:directory indexthumbnail galleryhighlighting (source-highlightorhighlight)cache thumbnails and highlights relative to current folderconfigurable root folderdockerfile