Skip to content

Commit

Permalink
use PORT variable if available
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronsw committed Nov 11, 2012
1 parent 8af2c4a commit ae36fdf
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions web/wsgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import http
import webapi as web
from utils import listget
from utils import listget, intget
from net import validaddr, validip
import httpserver

Expand Down Expand Up @@ -51,7 +51,12 @@ def runwsgi(func):
else:
return runscgi(func)

return httpserver.runsimple(func, validip(listget(sys.argv, 1, '')))

server_addr = validip(listget(sys.argv, 1, ''))
if os.environ.has_key('PORT'): # e.g. Heroku
server_addr = ('0.0.0.0', intget(os.environ['PORT']))

return httpserver.runsimple(func, server_addr)

def _is_dev_mode():
# Some embedded python interpreters won't have sys.arv
Expand Down

0 comments on commit ae36fdf

Please sign in to comment.