Ticket #360: django-server-addr.diff

File django-server-addr.diff, 2.5 KB (added by benno@…, 10 years ago)

Patch to add ip:port as well as port argument to runserver.

  • django/bin/django-admin.py

     
    8787        ACTION_MAPPING[action](name, os.getcwd())
    8888    elif action == 'runserver':
    8989        if len(args) < 2:
     90            addr = ''
    9091            port = '8000'
    9192        else:
    92             port = args[1]
    93         ACTION_MAPPING[action](port)
     93            if args[1].find(':') != -1:
     94                addr, port = args[1].split(':')
     95            else:
     96                addr = ''
     97                port = args[1]
     98        ACTION_MAPPING[action](addr, port)
    9499    else:
    95100        from django.core import meta
    96101        if action == 'dbcheck':
  • django/core/servers/basehttp.py

     
    636636        start_response(status, headers.items())
    637637        return output
    638638
    639 def run(port, wsgi_handler):
    640     server_address = ('', port)
     639def run(addr, port, wsgi_handler):
     640    server_address = (addr, port)
    641641    httpd = WSGIServer(server_address, WSGIRequestHandler)
    642642    httpd.set_app(wsgi_handler)
    643643    httpd.serve_forever()
  • django/core/management.py

     
    543543    print '%s error%s found.' % (num_errors, num_errors != 1 and 's' or '')
    544544validate.args = ''
    545545
    546 def runserver(port):
     546def runserver(addr, port):
    547547    "Starts a lightweight Web server for development."
    548548    from django.core.servers.basehttp import run, AdminMediaHandler, WSGIServerException
    549549    from django.core.handlers.wsgi import WSGIHandler
     
    555555        print "Validating models..."
    556556        validate()
    557557        print "\nStarting server on port %s with settings module %r." % (port, SETTINGS_MODULE)
    558         print "Go to http://127.0.0.1:%s/ for Django." % port
     558        print "Go to http://%s:%s/ for Django." % (addr, port)
    559559        print "Quit the server with CONTROL-C (Unix) or CTRL-BREAK (Windows)."
    560560        try:
    561             run(int(port), AdminMediaHandler(WSGIHandler()))
     561            run(addr, int(port), AdminMediaHandler(WSGIHandler()))
    562562        except WSGIServerException, e:
    563563            # Use helpful error messages instead of ugly tracebacks.
    564564            ERRORS = {
Back to Top