Django

Code

Changeset 539

Show
Ignore:
Timestamp:
08/19/05 16:23:56 (3 years ago)
Author:
adrian
Message:

Fixed #360 -- runserver now takes optional 'ip:port' in addition to 'port'. Thanks, benno@jeamland.net

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/django/bin/django-admin.py

    r503 r539  
    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            try: 
     94                addr, port = args[1].split(':') 
     95            except ValueError: 
     96                addr, port = '', args[1] 
     97        ACTION_MAPPING[action](addr, port) 
    9498    else: 
    9599        from django.core import meta 
  • django/trunk/django/core/management.py

    r509 r539  
    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 
     550    if not addr: 
     551        addr = '127.0.0.1' 
    550552    if not port.isdigit(): 
    551553        sys.stderr.write("Error: %r is not a valid port number.\n" % port) 
     
    556558        validate() 
    557559        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 
     560        print "Go to http://%s:%s/ for Django." % (addr, port) 
    559561        print "Quit the server with CONTROL-C (Unix) or CTRL-BREAK (Windows)." 
    560562        try: 
    561             run(int(port), AdminMediaHandler(WSGIHandler())) 
     563            run(addr, int(port), AdminMediaHandler(WSGIHandler())) 
    562564        except WSGIServerException, e: 
    563565            # Use helpful error messages instead of ugly tracebacks. 
     
    565567                13: "You don't have permission to access that port.", 
    566568                98: "That port is already in use.", 
     569                99: "That IP address can't be assigned-to.", 
    567570            } 
    568571            try: 
     
    576579    from django.utils import autoreload 
    577580    autoreload.main(inner_run) 
    578 runserver.args = '[optional port number]' 
     581runserver.args = '[optional port number, or ipaddr:port]' 
  • django/trunk/django/core/servers/basehttp.py

    r491 r539  
    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) 
  • django/trunk/docs/django-admin.txt

    r535 r539  
    8181Executes the equivalent of ``sqlall`` for the given app(s). 
    8282 
    83 runserver [optional port number
    84 -------------------------------- 
     83runserver [optional port number, or ipaddr:port
     84------------------------------------------------ 
    8585 
    8686Starts a lightweight development Web server on the local machine. By default, 
    87 the server runs on port 8000. You can pass in a port number explicitly. 
     87the server runs on port 8000 on the IP address 127.0.0.1. You can pass in an 
     88IP address and port number explicitly. 
    8889 
    8990If you run this script as a user with normal privileges (recommended), you 
     
    103104You can run as many servers as you want, as long as they're on separate ports. 
    104105Just execute ``django-admin.py runserver`` more than once. 
     106 
     107Examples: 
     108~~~~~~~~~ 
     109 
     110Port 7000 on IP address 127.0.0.1:: 
     111 
     112    django-admin.py runserver 7000 
     113 
     114Port 7000 on IP address 1.2.3.4:: 
     115 
     116    django-admin.py runserver 1.2.3.4:7000 
    105117 
    106118sql [app app ...]