Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Arbesko files application, built in Flask & Python
Branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.

Arbesko Files Application

This is in action right now on

It's an incredibly simple front-end to a directory of files. Take a look at util/ for all the various settings.


There are a few prerequisites for deployment. The below is based off of a vanilla Ubuntu 12.04 installation.

  • nginx
  • virtualenv

Step 0, deploy the project

Check out the git repository and move it into your desired production location. For our use, this is /var/www/files

Next, after installing virtualenv and virtualenvwrapper ensure that you have created a virtualenv and installed the required dependencies:

cd /var/www/files
pip install -r requirements.txt

This assumes that the git repository root is at /var/www/files, the location of requirements.txt

Step 1, nginx

After installing a recent build of nginx, you'll need to configure it. Below is a sample configuration:

# Arbesko Files App
# Flask + uWSGI

server {
    listen 80 default;

    root /home/arbesko/files/htdocs;

    charset utf-8;

    location /static {
        alias /var/www/;

    location / {
        include uwsgi_params;
        uwsgi_pass unix:///tmp/;

    location /download {
        alias /home/arbesko/files/htdocs;

In production, this is is saved as /etc/nginx/sites-available/

Which you'll then need to symlink into sites-enabled and restart nginx in order to take effect:

cd /etc/nginx/sites-enabled
ln -s ../sites-available/
sudo service nginx restart

This assumes that we have uwsgi running on the socket established at /tmp/ which leads us to our next configuration step.

Step 2, uWSGI

Note: uWSGI will be installed via the pip install -r requirements.txt command. If that does not go well, it's most likely due to missing dependencies. Those are installed via the following command on an Ubuntu/Debian box:

apt-get install build-essential python-dev libxml2-dev

The next step will involve configuring uWSGI and deploying it with supervisor to ensure that we can start and stop it. Also, supervisor will help us by automatically starting uWSGI when the server boots.

Install Supervisor

sudo apt-get install supervisor

Next, we'll create the config file to manage our uWSGI processes for this Files application:

cd /etc/supervisor/conf.d

We're now inside of vim, where we can enter our configuration. Copy and paste this into that file as a starting point:

    -s /tmp/
    -w files:app
    --processes 4
directory = /var/www/
environment = ARB_FILES_ROOT='/home/arbesko/files/htdocs'
user = www-data
autostart = true
autorestart = true
stdout_logfile = /var/log/arbesko/
redirect_stderr = true

The above config is mostly self-explanatory. We point to the binary for uWSGI that was added inside of our virtualenv.

The uWSGI parameters are of note:

  • -s /tmp/ this determines the socket which the app server operates on
  • -w files:app this determines the wsgi application that it will look for. In our case, the code for this can be seen by viewing in the root of the project.
  • -M tells uWSGI to operate in master mode
  • --processes 4 will run four processes, to increase concurrency
  • --max-requests=200 this is not required, but will kill a process after 200 requests to ensure any memory leakage is nipped in the bud.
  • --uid=www-data this runs the app servers as our www-data user
  • --chmod-socket this will make sure that the socket is owned by www-data as well, which allows nginx to communicate on it without any permissiosn errors.

Also of note is that we are setting the ARB_FILES_ROOT environment variable which determines where to serve files from. This is also configurable from inside of the util/ file in our app, but the ENV variable will take precedence if it is defined.

Start Her Up

At this point we can fire it all up and should see things working for us.

sudo /etc/init.d/supervisor start

If all goes well, you'll now see the files app running on your server. Try hitting it via your server ip or the domain defined.

Something went wrong with that request. Please try again.