parent
878183dbce
commit
32ca967d07
@ -0,0 +1,13 @@ |
||||
#!/usr/bin/env python |
||||
# -*- coding:utf-8 -*- |
||||
# project: 1月 |
||||
# author: NinEveN |
||||
# date: 2022/1/6 |
||||
from rest_framework.pagination import PageNumberPagination |
||||
|
||||
|
||||
class AppsPageNumber(PageNumberPagination): |
||||
page_size = 20 # 每页显示多少条 |
||||
page_size_query_param = 'limit' # URL中每页显示条数的参数 |
||||
page_query_param = 'page' # URL中页码的参数 |
||||
max_page_size = None # 最大页码数限制 |
@ -1,22 +0,0 @@ |
||||
import logging |
||||
|
||||
from django.utils.deprecation import MiddlewareMixin |
||||
|
||||
logger = logging.getLogger(__name__) |
||||
|
||||
|
||||
class CorsMiddleWare(MiddlewareMixin): |
||||
|
||||
def process_response(self, request, response): |
||||
if request.method == "OPTIONS": |
||||
response["Access-Control-Allow-Methods"] = "GET,POST,DELETE,PUT" |
||||
response["Access-Control-Allow-Headers"] = "Content-Type,AUTHORIZATION,x-token" |
||||
|
||||
try: |
||||
response["Access-Control-Allow-Origin"] = request.META.get("HTTP_ORIGIN") |
||||
response["Access-Control-Allow-Credentials"] = 'true' |
||||
|
||||
# response["Cache-Control"] = "no-cache" |
||||
except Exception as e: |
||||
logger.error(e) |
||||
return response |
Loading…
Reference in new issue