• 虚拟机 django 端口无法连接


    我的虚拟机django服务器为192.168.27.100,使用启动命令python manage.py runserver 9001启动后,发现笔记本电脑的游览器无法连接

    python@qinhan MyCrazyeyes]$ python manage.py runserver 9001
    Performing system checks...
    
    System check identified no issues (0 silenced).
    March 13, 2018 - 17:35:47
    Django version 2.0.1, using settings 'MyCrazyeyes.settings'
    Starting development server at http://127.0.0.1:9001/
    Quit the server with CONTROL-C.
    Performing system checks...

    经过百度发现首先要view settings.py ,将ALLOWED_HOSTS改为*

    [python@qinhan MyCrazyeyes]$ view settings.py 
    
    # Quick-start development settings - unsuitable for production
    # See https://docs.djangoproject.com/en/2.0/howto/deployment/checklist/
    
    # SECURITY WARNING: keep the secret key used in production secret!
    SECRET_KEY = '%7noe(d-i*qxjunhtg(bg8+rkyd3yzelz&3m-o3^_1*d!i04!f'
    
    # SECURITY WARNING: don't run with debug turned on in production!
    DEBUG = True
    
    ALLOWED_HOSTS = ['*']
    
    
    # Application definition
    
    INSTALLED_APPS = [
        'django.contrib.admin',
        'django.contrib.auth',
        'django.contrib.contenttypes',
        'django.contrib.sessions',
        'django.contrib.messages',
        'django.contrib.staticfiles',
        'web',
    ]

    随后启动命令必须用ip+端口方式启动

    ^C[python@qinhan MyCrazyeyes]$ python manage.py runserver 192.168.27.100:9001
    Performing system checks...
    
    System check identified no issues (0 silenced).
    March 13, 2018 - 17:43:35
    Django version 2.0.1, using settings 'MyCrazyeyes.settings'
    Starting development server at http://192.168.27.100:9001/
    Quit the server with CONTROL-C.

     这样就可以访问了

  • 相关阅读:
    三大家族的作用和区别
    正则表达式
    Math的方法
    数组API方法
    面向对象方法
    数组的常用方法
    对象和数组的遍历方法
    js运算符(运算符的结合性)
    i++和++i的运算符
    flex
  • 原文地址:https://www.cnblogs.com/qinhan/p/8571335.html
Copyright © 2020-2023  润新知