• 虚拟机 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.

     这样就可以访问了

  • 相关阅读:
    PTA(Basic Level)1048.数字加密
    PTA(Basic Level)1037.在霍格沃茨找零钱
    PTA(Basic Level)1030.完美数列
    PTA(Basic Level)1047.编程团体赛
    PTA(Basic Level)1087.有多少不同的值
    PTA(Basic Level)1077.互评成绩计算
    PTA(Basic Level)1027.打印沙漏
    PTA(Basic Level)1029.旧键盘
    记录一次排查挖矿:快速跟踪一个进程
    JVM性能、多线程排查常用命令
  • 原文地址:https://www.cnblogs.com/qinhan/p/8571335.html
Copyright © 2020-2023  润新知