Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from django.http import HttpResponse
- import urllib2
- import json
- def index(request):
- #defining endpoint variable
- endpoint="url here"
- #getting the data from the web
- serialized_data = urllib2.urlopen(endpoint).read()
- #serilize data to json
- output= json.loads(serialized_data)
- id=output['channels'][0]['feeds'][0]['entry_id']
- value=output['channels'][0]['feeds'][0]['value']
- created=output['channels'][0]['feeds'][0]['created_at']
- #html='test %s' %(id)
- html='<head> <title> komagal </title> </head> <body> <center> <p1> The result which is parsed from the API is : </p1> <br/> <p2> id : %s </p2> <br/> <p2> created at : %s</p2> <br/> <p2> value : %s</p2> </center> </body>' %(id,created,value)
- #setting the ouput
- return HttpResponse(html)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement