Add ability to set web-server port via API #21

nzjrs opened this Issue Jul 30, 2010 · 7 comments


None yet
3 participants

nzjrs commented Jul 30, 2010


I am using as an embedded webserver in my app. Because there is no way to set the port served programatically I have to do this

    import sys; sys.argv[1] = '8080'    #Yuck = web.application(xxxx)
    thread.start_new_thread(, ())

Otherwise webpy assumes the first command line argument it its port (which it is not as my app has many other command line args)


anandology commented Aug 26, 2010

How about making it take from web.config if specified? Something like this:

web.config.default_port = 8090

nzjrs commented Aug 26, 2010

I guess that would be sufficient, however I would prefer it be per application (config is global, right?).

Although not needed in my case, someone else might wish to run multiple servers on different ports.

nzjrs commented Aug 26, 2010

Actually I just saw that config seems to hold other global state (smtp config for example), so there is precident.

web.config.default_port makes sense in that case.


anandology commented Aug 26, 2010

we might want to support specifying the interface too. to bind only on localhost.
Should we call it default_bind_address?

web.ctx.default_bind_address = ''

or just port:

web.ctx.default_bind_address = 9000

nzjrs commented Aug 26, 2010

How about just calling it interface?

web.ctx.default_interface =

And, in the port only case

web.ctx.default_interface = :9000

(i.e. starts with ':')


anandology commented Nov 12, 2010

This can be solved by calling runsimple like this.

if __name__ == "__main__":
   web.httpserver.runsimple(app.wsgifunc(), ("", 8888))

serverhorror commented Mar 17, 2011

For the port only case in web.ctx.default_interface

web.ctx.default_interface = ::1

Do I now listen on port 1 with the default interface or on IPv6 loopback and the default port? Of course this:

web.ctx.default_interface = '[::1]'

would make it clear for IPv6.

I'd like a a default_address (as interfaces can have multiple addresses) and a default_port. Keeping with the explicit is better than implicit (pep-0020, second line in the zen of python) - yes I'm being a smartass here. Sorry :)

This issue was closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment