Skip to content

Commit 1c33735

Browse files
committed
版本 v1.0.1
修补 生产环境时的BUG,默认为生产环境
1 parent f9aaa7e commit 1c33735

5 files changed

Lines changed: 32 additions & 27 deletions

File tree

README.md

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,24 @@
99

1010
![image-20210421180717445](http://img.xzaslxr.xyz/image-20210421180717445.png)
1111

12-
配置python 环境
12+
配置环境
1313
```bash
14-
python -m pip install -r requirements.txt
14+
python3 -m pip install -r requirements.txt
15+
python3 manage.py makemigrations
16+
python3 manage.py migrate
17+
python3 manage.py collectstatic
18+
python3 manage.py createsuperuser
1519
```
1620

1721
`celery`中设置`worker``redis`,需要
1822
```bash
19-
`docker run --name=redis -d -p 6379:6379 redis`
23+
docker pull redis:latest
24+
docker run --name=redis -d -p 6379:6379 redis
25+
```
26+
27+
`settings.py`添加
28+
```python
29+
ALLOWED_HOSTS = ['*']
2030
```
2131

2232
`celery`启动

ScanWebShell/settings.example.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
"""
1212

1313
from pathlib import Path
14+
import os
15+
1416

1517
# Build paths inside the project like this: BASE_DIR / 'subdir'.
1618
BASE_DIR = Path(__file__).resolve().parent.parent
@@ -23,9 +25,9 @@
2325
SECRET_KEY = ''
2426

2527
# SECURITY WARNING: don't run with debug turned on in production!
26-
DEBUG = True
28+
DEBUG = False
2729

28-
ALLOWED_HOSTS = []
30+
ALLOWED_HOSTS = [ '*' ]
2931

3032

3133
# Application definition
@@ -124,6 +126,13 @@
124126

125127
STATIC_URL = '/static/'
126128

129+
if DEBUG:
130+
STATICFILES_DIRS = [
131+
os.path.join(BASE_DIR, 'static')
132+
]
133+
else:
134+
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
135+
127136
# Default primary key field type
128137
# https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field
129138

@@ -133,7 +142,7 @@
133142
# 发送邮件配置
134143
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
135144
# smpt服务地址
136-
EMAIL_HOST = 'smtp.qq.com'
145+
EMAIL_HOST = ''
137146
EMAIL_PORT = 25 # 端口默认都是25不需要修改
138147
# 发送邮件的邮箱,需要配置开通SMTP
139148
EMAIL_HOST_USER = ''

ScanWebShell/urls.py

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,17 @@
1-
"""ScanWebShell URL Configuration
2-
3-
The `urlpatterns` list routes URLs to views. For more information please see:
4-
https://docs.djangoproject.com/en/3.2/topics/http/urls/
5-
Examples:
6-
Function views
7-
1. Add an import: from my_app import views
8-
2. Add a URL to urlpatterns: path('', views.home, name='home')
9-
Class-based views
10-
1. Add an import: from other_app.views import Home
11-
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
12-
Including another URLconf
13-
1. Import the include() function: from django.urls import include, path
14-
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
15-
"""
1+
from django.conf.urls import url
162
from django.contrib import admin
173
from django.urls import path,include
4+
from django.views.static import serve
185
from ScanWebShell import views
6+
from django.conf import settings
197

20-
import user.views
218

229
urlpatterns = [
2310
path('', views.index), # 首页
2411
path('index/', views.index), # 首页
2512
path('admin/', admin.site.urls),
2613
path('user/', include('user.urls')),
2714
path('job/',include('job.urls')),
28-
path('captcha/', include('captcha.urls'))
15+
path('captcha/', include('captcha.urls')),
16+
url(r"^static/(?P<path>.*)$", serve, {"document_root": settings.STATIC_ROOT}, name='static'),
2917
]

job/migrations/0001_initial.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class Migration(migrations.Migration):
1010

1111
dependencies = [
1212
('user', '0001_initial'),
13-
('django_celery_results', '0009_auto_20210416_2010'),
13+
# ('django_celery_results', '0009_auto_20210416_2010'), 该参数可能会有问题
1414
]
1515

1616
operations = [

requirements.txt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,8 @@ django-ranged-response==0.2.0
1818
django-simple-captcha==0.5.14
1919
humanize==3.4.1
2020
idna==2.10
21+
joblib=1.0.1
2122
mccabe==0.6.1
22-
mkl-fft==1.3.0
23-
mkl-random==1.1.1
24-
mkl-service==2.3.0
2523
msgpack==1.0.2
2624
Pillow==8.1.2
2725
prometheus-client==0.8.0

0 commit comments

Comments
 (0)