You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
1.6 KiB
42 lines
1.6 KiB
11 months ago
|
import requests
|
||
|
from update.models import Cinema
|
||
|
from django.http.response import JsonResponse
|
||
|
from mock.mock_templates import *
|
||
|
|
||
|
ZZ_URL = 'https://zzcs.yinghezhong.com'
|
||
|
|
||
|
|
||
|
def mock(_ip, _api, *args, **kwargs):
|
||
|
print('mock')
|
||
|
cinema_obj = Cinema.objects.filter(ip=_ip).first()
|
||
|
if _api == 'getCinemaInfo':
|
||
|
mock_data = get_cinema_info_tmp.get(cinema_obj)
|
||
|
return JsonResponse(mock_data, json_dumps_params={'ensure_ascii': False})
|
||
|
if _api == 'reportTicket':
|
||
|
mock_data = report_ticket_tmp.get()
|
||
|
return JsonResponse(mock_data, json_dumps_params={'ensure_ascii': False})
|
||
|
|
||
|
def bypass(_r):
|
||
|
print('bypass')
|
||
|
print(_r.method, _r.path) # GET /data/getCinemaInfo
|
||
|
print(_r.GET) # <QueryDict: {'cinemaCode': ['14105121'], 'sign': ['f7ca26e79abd3d2225e348da66463fbf'], 'timeStamp': ['1703119043']}>
|
||
|
print(_r.POST)
|
||
|
if _r.method == 'GET':
|
||
|
req_url = ZZ_URL + _r.path
|
||
|
req_params = dict(_r.GET)
|
||
|
print(req_url)
|
||
|
print(req_params)
|
||
|
response_dara = requests.get(req_url, params=req_params)
|
||
|
print(response_dara.json())
|
||
|
return JsonResponse(response_dara.json(), json_dumps_params={'ensure_ascii': False})
|
||
|
if _r.method == 'POST':
|
||
|
req_url = ZZ_URL + _r.path
|
||
|
req_params = dict(_r.GET)
|
||
|
req_data = dict(_r.POST)
|
||
|
print(req_url)
|
||
|
print(req_params)
|
||
|
print(req_data)
|
||
|
response_dara = requests.post(req_url, params=req_params, data=req_data)
|
||
|
print(response_dara.json())
|
||
|
return JsonResponse(response_dara.json(), json_dumps_params={'ensure_ascii': False})
|