· 7 years ago · Feb 27, 2018, 06:44 AM
1GET http://localhost:8000/static/rest_framework/css/bootstrap.min.css net::ERR_ABORTED
2localhost/:20 GET http://localhost:8000/static/rest_framework/css/bootstrap-tweaks.css net::ERR_ABORTED
3localhost/:23 GET http://localhost:8000/static/rest_framework/css/prettify.css net::ERR_ABORTED
4localhost/:24 GET http://localhost:8000/static/rest_framework/css/default.css net::ERR_ABORTED
5(index):219 GET http://localhost:8000/static/rest_framework/js/ajax-form.js net::ERR_ABORTED
6(index):218 GET http://localhost:8000/static/rest_framework/js/jquery-1.12.4.min.js net::ERR_ABORTED
7(index):220 GET http://localhost:8000/static/rest_framework/js/csrf.js net::ERR_ABORTED
8(index):221 GET http://localhost:8000/static/rest_framework/js/bootstrap.min.js net::ERR_ABORTED
9(index):222 GET http://localhost:8000/static/rest_framework/js/prettify-min.js net::ERR_ABORTED
10(index):223 GET http://localhost:8000/static/rest_framework/js/default.js net::ERR_ABORTED
11(index):219 GET http://localhost:8000/static/rest_framework/js/ajax-form.js 404 (Not Found)
12(index):220 GET http://localhost:8000/static/rest_framework/js/csrf.js net::ERR_ABORTED
13(index):221 GET http://localhost:8000/static/rest_framework/js/bootstrap.min.js net::ERR_ABORTED
14(index):222 GET http://localhost:8000/static/rest_framework/js/prettify-min.js net::ERR_ABORTED
15(index):223 GET http://localhost:8000/static/rest_framework/js/default.js net::ERR_ABORTED
16
17Django (1.11.1)
18django-rest-auth (0.9.2)
19djangorestframework (3.7.1)
20
21os.environ.setdefault("DJANGO_SETTINGS_MODULE", "Qyun.settings")
22
23#application = get_wsgi_application()
24
25from socketio import Middleware
26from xxx.website_chat.views import sio
27django_app = get_wsgi_application()
28application = Middleware(sio, django_app)
29
30import eventlet
31import eventlet.wsgi
32eventlet.wsgi.server(eventlet.listen(('', 8000)), application)
33
34# -*- coding: utf-8 -*-
35
36"""
37Django settings for Qiyun02 project.
38
39Generated by 'django-admin startproject' using Django 1.11.5.
40
41For more information on this file, see
42https://docs.djangoproject.com/en/1.11/topics/settings/
43
44For the full list of settings and their values, see
45https://docs.djangoproject.com/en/1.11/ref/settings/
46"""
47
48import os
49import sys
50
51#import django.contrib.auth.middleware
52
53# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
54BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
55PARENT_DIR = os.path.abspath(os.path.join(BASE_DIR, os.pardir))
56
57# å¢žåŠ sys目录
58sys.path.insert(0, BASE_DIR)
59sys.path.insert(0, os.path.join(PARENT_DIR,'旗云管ç†å‘˜åŽå°'))
60sys.path.insert(0, os.path.join(PARENT_DIR,'用户å‰å°'))
61sys.path.insert(0, os.path.join(PARENT_DIR,'用户管ç†åŽå°'))
62
63
64# Quick-start development settings - unsuitable for production
65# See https://docs.djangoproject.com/en/1.11/howto/deployment/checklist/
66
67# SECURITY WARNING: keep the secret key used in production secret!
68SECRET_KEY = 'u8ctyimjuy7t-7r3%$&4sc2g^5fhc8dathp8z&(7pp=&eee@zn'
69
70# SECURITY WARNING: don't run with debug turned on in production!
71DEBUG = True
72
73ALLOWED_HOSTS = ['*']
74
75
76# Application definition
77
78
79INSTALLED_APPS = [
80
81 'django.contrib.admin',
82 'django.contrib.auth',
83 'django.contrib.contenttypes',
84 'django.contrib.sessions',
85 'django.contrib.messages',
86 'django.contrib.staticfiles',
87 'django.contrib.sites',
88
89 'corsheaders', # 跨域头
90
91 'rest_framework',
92 'rest_framework.authtoken',
93 'rest_framework_docs', # API文档
94 'rest_auth',
95 'allauth',
96 'allauth.account',
97 'allauth.socialaccount',
98 'rest_auth.registration',
99
100
101 # apps
102 ......
103
104]
105
106SITE_ID = 1
107
108
109# email backend TODO
110EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
111
112#EMAIL_USE_TLS = True
113EMAIL_USE_SSL = True
114EMAIL_HOST = 'smtp.gmail.com' # QQ:smtp.qq.com 163:smtp.163.com
115EMAIL_PORT = 465
116EMAIL_HOST_USER = 'qiyunserver@gmail.com'
117EMAIL_HOST_PASSWORD = 'qiyunserver123'
118DEFAULT_FROM_EMAIL = EMAIL_HOST_USER
119
120
121# TODO 方便调试,关é—Token验è¯
122REST_FRAMEWORK = {
123 'DEFAULT_PERMISSION_CLASSES':[], #'rest_framework.permissions.IsAuthenticated'
124 'DEFAULT_AUTHENTICATION_CLASSES':(
125 'rest_framework.authentication.TokenAuthentication',
126 'rest_framework.authentication.SessionAuthentication',
127 ), #['rest_framework.authentication.TokenAuthentication'], # 'rest_framework.authentication.TokenAuthentication'
128 #'DEFAULT_PAGINATION_CLASS': ('rest_framework.pagination.PageNumberPagination',), ä¸èƒ½æ‰“开这个
129 #'PAGE_SIZE':10,
130}
131
132
133REST_AUTH_SERIALIZERS = {
134 'LOGIN_SERIALIZER': 'Qiyun02.common.Serializer.LoginSerializer',
135 'TOKEN_SERIALIZER': 'Qiyun02.common.Serializer.TokenSerializer',
136}
137
138
139MIDDLEWARE = [
140 'django.middleware.security.SecurityMiddleware',
141 'django.contrib.sessions.middleware.SessionMiddleware',
142
143 'corsheaders.middleware.CorsMiddleware',
144 'django.middleware.common.CommonMiddleware',
145
146 'django.middleware.csrf.CsrfViewMiddleware',
147 'corsheaders.middleware.CorsPostCsrfMiddleware',
148
149 'django.contrib.auth.middleware.AuthenticationMiddleware',
150 'django.contrib.messages.middleware.MessageMiddleware',
151 'django.middleware.clickjacking.XFrameOptionsMiddleware',
152
153 'Qiyun02.middlewares.AccessControlMiddleware.AccessControl', # access-controlä¸é—´ä»¶
154
155]
156
157# TODO: å‘布时候去掉
158CORS_ALLOW_METHODS = [
159 'DELETE',
160 'GET',
161 'OPTIONS',
162 'PATCH',
163 'POST',
164 'PUT',
165]
166
167# TODO: å‘布时候去掉
168CORS_ALLOW_HEADERS = (
169 'XMLHttpRequest',
170 'X_FILENAME',
171 'accept-encoding',
172 'accept',
173 'accept-encoding',
174 'authorization',
175 'content-type',
176 'dnt',
177 'origin',
178 'user-agent',
179 'x-csrftoken',
180 'x-requested-with',
181)
182# TODO: å‘布时候去掉
183CORS_ORIGIN_ALLOW_ALL = False
184
185CORS_ALLOW_CREDENTIALS = True
186
187CORS_ORIGIN_WHITELIST = (
188
189 'http://10.10.10.102:8081',
190 'http://10.10.10.103:8000',
191 'http://10.10.10.103:8080',
192 'http://10.10.10.105:8000',
193 'http://10.10.10.105:8001',
194 'http://10.10.10.105:8080',
195
196 'http://0.0.0.0:8000',
197 'http://0.0.0.0:8001',
198 'http://0.0.0.0:8080',
199
200 'http://localhost:8081',
201 'http://localhost',
202)
203
204######
205
206ROOT_URLCONF = 'Qiyun02.urls'
207
208TEMPLATES = [
209 {
210 'BACKEND': 'django.template.backends.django.DjangoTemplates',
211 'DIRS': [os.path.join(BASE_DIR, 'templates')]
212 ,
213 'APP_DIRS': True,
214 'OPTIONS': {
215 'context_processors': [
216 'django.template.context_processors.debug',
217 'django.template.context_processors.request',
218 'django.contrib.auth.context_processors.auth',
219 'django.contrib.messages.context_processors.messages',
220 ],
221 },
222 },
223]
224
225WSGI_APPLICATION = 'Qiyun02.wsgi.application'
226
227
228# Database
229# https://docs.djangoproject.com/en/1.11/ref/settings/#databases
230
231DATABASES = {
232 'default': {
233 'ENGINE': 'django.db.backends.mysql',
234 'NAME': 'qiyun02',
235 'USER':'root',
236 'PASSWORD':'devops',
237 'HOST':'127.0.0.1',
238 'PORT':'3306',
239 }
240}
241
242
243# Password validation
244# https://docs.djangoproject.com/en/1.11/ref/settings/#auth-password-validators
245
246AUTH_PASSWORD_VALIDATORS = [
247 {
248 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
249 },
250 {
251 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
252 },
253 {
254 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
255 },
256 {
257 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
258 },
259]
260
261
262# Internationalization
263# https://docs.djangoproject.com/en/1.11/topics/i18n/
264
265LANGUAGE_CODE = 'zh-cn' # 'en-us'
266
267TIME_ZONE = 'Asia/Shanghai'
268
269USE_I18N = True
270
271USE_L10N = True
272
273USE_TZ = True
274
275
276# Static files (CSS, JavaScript, Images)
277# https://docs.djangoproject.com/en/1.11/howto/static-files/
278
279
280STATIC_URL = '/static/'
281STATICFILES_DIRS = (
282 os.path.join(BASE_DIR, 'static'),
283)
284
285MEDIA_URL = '/media/'
286MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
287
288STATIC_ROOT = BASE_DIR + '/static/'
289STATIC_URL = '/static/'
290STATICFILES_DIRS = (
291 os.path.join(BASE_DIR, 'static'),
292)
293
294import os
295
296from django.core.wsgi import get_wsgi_application
297
298os.environ.setdefault("DJANGO_SETTINGS_MODULE", "Qiyun02.settings")
299
300application = get_wsgi_application()