fixed some bugs

This commit is contained in:
lzh
2020-07-14 01:45:19 +08:00
parent 3fb7c1e96e
commit cf503387b7
5 changed files with 15 additions and 10 deletions
@@ -43,7 +43,7 @@ MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
# 'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
@@ -54,7 +54,7 @@ ROOT_URLCONF = 'Django_study.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(BASE_DIR, 'templates')]
'DIRS': [os.path.join(BASE_DIR, 'static')]
,
'APP_DIRS': True,
'OPTIONS': {
+3 -1
View File
@@ -19,7 +19,9 @@ from django.http import HttpResponse
from django.conf.urls import url
from Django_study import views
urlpatterns = [
url(r'^$', views.home),
path('',views.home),
path(r'main.html/', views.home2,name='main'),
path('admin/', admin.site.urls),
]
+6 -5
View File
@@ -1,10 +1,11 @@
import os
from django.http import HttpResponse
from django.conf import settings
from django.views.decorators.csrf import csrf_exempt
from django.shortcuts import render, reverse, redirect
def home(request):
path=os.path.join(settings.BASE_DIR,'static','index.html')
html=''
with open(path,'r',encoding='utf-8') as f :
html=f.read()
return render(request,'../static/index.html')
return HttpResponse(html)
def home2(request):
return render(request,'../static/main.html')
+3 -1
View File
@@ -34,7 +34,9 @@
</head>
<body>
<form action="./main.html" class="login-form" method="post" onsubmit="return login()">
<form action="./main.html/" class="login-form" method="post" onsubmit="return login()" >
<h1>在线聊天系统</h1>
<input type="text" name="nickname" required="true">
<input type="submit" value="登录">
+1 -1
View File
@@ -28,7 +28,7 @@
<script type="text/javascript">
var ws//websocket连接对象
var url='ws://localhost:8000/'
var url='ws://127.0.0.1:8000/main.html/'
//消息内容显示
var chat_main =document.getElementsByClassName('chat-main')[0]
window.onload=function () {