diff --git a/public_sentiment/settings.py b/public_sentiment/settings.py index a630da9..01f4c9a 100644 --- a/public_sentiment/settings.py +++ b/public_sentiment/settings.py @@ -35,22 +35,20 @@ INSTALLED_APPS = [ 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', - 'rest_framework', - 'rest_framework_swagger', 'web', ] # swagger 配置项 # SWAGGER_SETTINGS = { # # 基础样式 -# # 'SECURITY_DEFINITIONS': { -# # "basic": { -# # 'type': 'basic' -# # } -# # }, +# 'SECURITY_DEFINITIONS': { +# "basic": { +# 'type': 'basic' +# } +# }, # # 如果需要登录才能够查看接口文档, 登录的链接使用restframework自带的. -# # 'LOGIN_URL': 'rest_framework:login', -# # 'LOGOUT_URL': 'rest_framework:logout', +# 'LOGIN_URL': 'rest_framework:login', +# 'LOGOUT_URL': 'rest_framework:logout', # # 'DOC_EXPANSION': None, # # 'SHOW_REQUEST_HEADERS':True, # # 'USE_SESSION_AUTH': True, @@ -64,11 +62,11 @@ INSTALLED_APPS = [ # 'VALIDATOR_URL': None, # } -REST_FRAMEWORK = { - 'DEFAULT_PERMISSION_CLASSES': [ - 'rest_framework.permissions.IsAuthenticated', - ] -} +# REST_FRAMEWORK = { +# 'DEFAULT_PERMISSION_CLASSES': [ +# 'rest_framework.permissions.IsAuthenticated', +# ] +# } MIDDLEWARE = [ 'django.middleware.security.SecurityMiddleware', diff --git a/public_sentiment/urls.py b/public_sentiment/urls.py index cab8a85..60a6f0a 100644 --- a/public_sentiment/urls.py +++ b/public_sentiment/urls.py @@ -14,53 +14,13 @@ Including another URLconf 1. Import the include() function: from django.urls import include, path 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) """ -from django.db import router -from django.urls import path -from drf_yasg import openapi -from drf_yasg.views import get_schema_view -from rest_framework import permissions, routers -from django.contrib import admin -from rest_framework import routers -from django.conf.urls import include -from rest_framework.routers import DefaultRouter -from rest_framework.schemas.views import SchemaView -from tornado.web import url -from web import views +from django.contrib import admin +from django.urls import path from web.controller.html_parser_controller import HtmlParserController from web.controller.schedule_controller import SchedulerController -# Swagger documentation setup -# schema_view = get_schema_view( -# openapi.Info( -# title="舆情系统API", -# default_version='v1', -# description="舆情系统API", -# terms_of_service="https://www.google.com/policies/terms/", -# contact=openapi.Contact(email="contact@snippets.local"), -# license=openapi.License(name="BSD License"), -# ), -# public=True, -# permission_classes=(permissions.AllowAny,), -# ) - - -# 重要的是如下三行 -from rest_framework.schemas import get_schema_view -from rest_framework_swagger.renderers import SwaggerUIRenderer, OpenAPIRenderer - -schema_view = get_schema_view(title='Users API', renderer_classes=[OpenAPIRenderer, SwaggerUIRenderer]) - -router = routers.DefaultRouter() -# router.register('users', views.UserViewSet, base_name='user') -# router.register('groups', views.GroupViewSet, base_name='group') - urlpatterns = [ - path('admin/', admin.site.urls), - path('', include(router.urls)), - path('api-auth/', include('rest_framework.urls', namespace='rest_framework')), - path('docs/', schema_view, name='docs'), - path('admin/', admin.site.urls), path('api/v1/htmlParser/parseHtml', HtmlParserController().parse_html), path('api/v1/scheduler/create', SchedulerController().create), diff --git a/web/controller/html_parser_controller.py b/web/controller/html_parser_controller.py index 3f17c5f..952931c 100644 --- a/web/controller/html_parser_controller.py +++ b/web/controller/html_parser_controller.py @@ -1,16 +1,10 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -import json -from collections import namedtuple from django.http import JsonResponse from rest_framework.decorators import api_view from rest_framework.views import APIView -from twisted.protocols.amp import Box -from collector.spiders.collector_spider import CollectorSpider from web.controller.base_controller import BaseController -from web.dto.api_result import ApiResult -from web.manager.gridgraph_manager import GridGraphManager from web.manager.log_manager import LogManager from web.util.dto_util import DtoUtil from web.vo.parse_html_vo import ParseHtmlVo diff --git a/web/serializers.py b/web/serializers.py deleted file mode 100644 index 81c3a8c..0000000 --- a/web/serializers.py +++ /dev/null @@ -1,18 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -from rest_framework import serializers -from web.models.training_sensitive_word import TrainingSensitiveWord - - -# 序列化模型为其他格式 - -class TrainingSensitiveWordSerializer(serializers.ModelSerializer): - class Meta: - model = TrainingSensitiveWord - - # 序列化所有的字段 - fields = '__all__' - - # 序列化部分字段 - # fields = ('id','song','singer','last_modify_date','created') diff --git a/web/views.py b/web/views.py index aaeb9c3..faa18be 100644 --- a/web/views.py +++ b/web/views.py @@ -1,42 +1,2 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- - -from rest_framework import viewsets -from rest_framework.parsers import MultiPartParser, FormParser, JSONParser - -from web.models import TrainingSensitiveWord -from web.serializers import TrainingSensitiveWordSerializer - - -class TrainingSensitiveWordSerializerViewSet(viewsets.ModelViewSet): - """ - CRUD 功能 - """ - authentication_classes = [] - permission_classes = [] - - # 解析方式 - parser_classes = (MultiPartParser, FormParser, JSONParser) - - queryset = TrainingSensitiveWord.objects.all() - serializer_class = TrainingSensitiveWordSerializer - - def create(self, request, *args, **kwargs): - """新建一条音乐""" - pass - - def list(self, request, *args, **kwargs): - """全部音乐数据""" - pass - - def retrieve(self, request, *args, **kwargs): - """查询一条数据""" - pass - - def update(self, request, *args, **kwargs): - """更新一条音乐数据""" - pass - - def destroy(self, request, *args, **kwargs): - """删除一条数据""" - pass \ No newline at end of file