Trabzon, August 2015 - Oneplus One

For my latest project, I implemented subdomain handling, however, I wasn’t able to test it from my local; pushing to production and try from the real domain and subdomain was so hard. When I look at the tutorials, they are mostly php stuff containing apache2 configurations, virtualhosts etc. I needed a simple method for this.

  • Modify content of hosts file

$ sudo nano /etc/hosts

  • Example configuration	localhost   hakan.localhost
  • Install just for the sake of trial.

$ sudo easy_install

  • Create a file

$ touch

  • Paste this content:
import web
urls = (
    '/(.*)', 'hello'
app = web.application(urls, globals())

class hello:        
    def GET(self, name):
        if not name: 
            name = 'World'
        return 'Hello, ' + name + '!'

if __name__ == "__main__":
  • Run the file.

$ python

Open browser and go: <hakan.localhost:8080/>