Last active
December 23, 2015 18:39
-
-
Save jumbojet/6677454 to your computer and use it in GitHub Desktop.
sample view
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_units(request): | |
# request object has one GET DICTIONARY for the variables passed as Query String | |
# Query string variable is named as ID | |
if 'ID' in request.GET: | |
userId = request.GET['ID'] | |
# request object has one POST DICTIONARY for the variables passed as form.submit() | |
# Here assume a form variable is named as UNITS | |
if 'UNITS' in request.POST: | |
units = request.POST['UNITS'] | |
readingData = get_units_data(userId) | |
output_json = jsonpickle.encode(readingData) #unpickled = jsonpickle.decode(output_json) | |
''' Here we are able to send JSON as htttp response. Comes in handy for API writting''' | |
return HttpResponse(output_json) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment