Django runserver from Python script

前端 未结 1 1728
粉色の甜心
粉色の甜心 2020-12-10 07:36

The normal way to start the Django server is to run the following command from a terminal or a bash script:

python manage.py runserver [Ip.addr]:[port] 
         


        
1条回答
  •  醉梦人生
    2020-12-10 08:04

    Python has already builtin HTTP server

    python -m SimpleHTTPServer
    

    OR you have an alternative to run the django server

    os.environ.setdefault("DJANGO_SETTINGS_MODULE", "server.settings")
    
    from django.core.management import call_command
    from django.core.wsgi import get_wsgi_application 
    application = get_wsgi_application()
    call_command('runserver',  '127.0.0.1:8000')
    

    0 讨论(0)
提交回复
热议问题