Пример #1
0
def searchCompound(request):
	try:
		data = json.loads(request.body)
		try:
			token = Token.objects.filter(token=data['token']).first()
			user = token.user
		except:
			raise myError('Please Log In.')
		keyword = data['keyword']
		search_result = search_compound(keyword)
		result = {
			'successful': True,
			'data': search_result,
			'error': {
				'id': '',
				'msg': '',
			},
		}
	except myError, e:
		result = {
			'successful': False,
			'error': {
				'id': '3',
				'msg': e.value,
			}
		}
Пример #2
0
def searchCompound(request):
    keyword = request.GET.get('keyword')
    result = search_compound(keyword)
    return HttpResponse(json.dumps(result), content_type='application/json')