一、 练习连接
https://docs.djangoproject.com/en/2.1/intro/tutorial01/
二、 新建polls的app
python manage.py startapp polls
三、 修改view.py
# polls/views.py
from django.http import HttpResponse
def index(request):
return HttpResponse("Hello, world. You're at the polls index.")
四、 在polls文件夹中增加urls.py
# polls/urls.py
from django.urls import path
from . import views
urlpatterns = [
path('', views.index, name='index'),
]
五、修改配置
1.修改mysite中的urls.py
# mysite/urls.py
from django.contrib import admin
from django.urls import include, path
urlpatterns = [
path('admin/', admin.site.urls),
path('polls/', include('polls.urls')),
]
2.修改mysite中的settings.py,的访问限制
ALLOWED_HOSTS = ['*']
六、启动server
python manage.py runserver 0.0.0.0:8000
# 之前尝试可以的命令,2020.10.28用不了了
# python manage.py runserver_plus --cert server.crt 172.24.31.181:8080
七、通过chrom查看
http://172.24.17.236:8000/polls/
https://172.24.31.181:8080/polls/