If you host multiple (virtual hosting) python web apps (django, flask etc) behind nginx on a single server, you have two options:

  1. Using subdomains
  2. On different URL mount points

Using subdomains, you will have to update your DNS records for every app that you deploy. While the deployment is cleaner (no sharing of cookies etc), this requires a little more effort to setup.

With the second method ie different URL mounts, you don't have to update any DNS record but there is a chance of cookies getting overwritten if you aren't careful.

The gunicorn server handles multiple URL mount points through the SCRIPT_NAME header set by the reverse proxy (in our case nginx).

Here's an nginx config snippet of hosting two different apps A at /abc/ and B at /def/. So when you visit say /abc/about/ and /def/about/, you are visiting the /about/ URL on the apps A and B respectively.

server {

   location /abc {
        proxy_pass http://localhost:8001;
        include proxy_params;
        proxy_set_header SCRIPT_NAME /abc;

   location /def {
        proxy_pass http://localhost:8002;
        include proxy_params;
        proxy_set_header SCRIPT_NAME /def;

Elasticsearch autocomplete on related keywords

Thu 21 April 2016 by Thejaswi Puthraya

Recently, I had to work on a client request to add autocomplete to their site's search based not just on a specific list but on related keywords.

For example, suppose you had a list of TV series like Simpsons, Futurama, Tom and Jerry etc. The autosearch had to suggest the …

read more

Simple Command Line Dropbox Uploader in Python

Sun 10 April 2016 by Thejaswi Puthraya

I don't use Dropbox frequently. In fact, I would prefer not to use it but work requires me to use it from time to time. My only use case was to upload files onto a shared folder. So for my usage, it makes no sense to run the desktop client …

read more

Changing fonts for Platypus document templates in reportlab

Tue 30 November 2010 by Thejaswi Puthraya

If you've wanted to generate PDF reports in python, you don't have choices. Most of the so called alternatives are also built on top of 'reportlab'.

I am not comfortable with reportlab (this is a post in itself) but because there's no viable alternative, I have stuck on. Reportlab has …

read more

Learning Python 1

Tue 08 April 2008 by Thejaswi Puthraya

Interesting aspect of Python : 1

Yesterday I learnt an interesting aspect of python called closures.

def a(aa1, aa2=10):
     def b(bb1, bb2=aa2):
             print aa1, aa2, bb1, bb2
     return b

>>> a(20)(5)

What is the output?

The answer by intuition would have been …

read more

Launch of Safebrowsing-python

Thu 17 January 2008 by Thejaswi Puthraya

Launch of Safebrowsing-python

Today I launched my second project online after django-check-constraints, safebrowsing-python. The project is based on the Google Safebrowsing API. Check out the announcement on the google-safebrowsing-api mailing list and also the usage wiki page at the project home.

Wish you a happy and safe browsing on the …

read more

An Idle Mind is a Devil's Workshop

Sat 12 January 2008 by Thejaswi Puthraya

An idle mind is a devil's workshop

On thursday, my previous semester results were out. I logged on to the site and checked out my result. My result was anything but surprising. Then I thought to myself, "Why not give people the freedom to compare their marks with their peers' …

read more

I blog in ReSt Part 3

Sun 11 November 2007 by Thejaswi Puthraya

I blog in ReSt Part 3

This is the final part in the "I blog in ReSt" series. This part discusses about how to get the templates going for the blog.

  • Create a folder called templates in the project directory and add the absolute path to the directory in the …
read more

I blog in ReSt Part 2

Sat 10 November 2007 by Thejaswi Puthraya

I blog in ReSt Part 2

Once done with setting up the project, we need to code our views and templates to complete the blog. This part deals with coding the views for the blog. The different views that we require are

  • For displaying the landing page
  • For displaying the …
read more

I blog in ReSt Part 1

Fri 09 November 2007 by Thejaswi Puthraya

I blog in ReStructured Text Part-1

Nowadays everyone blogs. Blogs have become the medium for people to express almost everything. So I started blogging in January on Blogger. Initially I was satisfied with it but started feeling cramped for features. Wordpress and PyBlosxom looked like good alternatives but it was …

read more