Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(748)

Unified Diff: simple_get_post.py

Issue 334790043: This is a test GET post (Closed)
Patch Set: Simple Network Topology Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: simple_get_post.py
diff --git a/simple_get_post.py b/simple_get_post.py
index 4d169670d76228c0f70be66fbae999d1ba1525c5..8b02379329da3224955169be46e024050ce905b1 100644
--- a/simple_get_post.py
+++ b/simple_get_post.py
@@ -1,37 +1,54 @@
import httplib
-import urllib
-import urllib2
+from urllib2 import urlopen
import requests
+import json
-url = 'http://192.16.125.183/API_REST/request.php'
-#Passing parameters with URLs
-#e.g http://192.16.125.183/API_REST/request.php/get?key=val
+Class GetFunction():
+
-payload = {'key1': 'value1', 'key2': 'value2'}
+def __init__(self, key1, key2):
+
+
+url = 'http://192.16.125.183/API_REST/request.php'
+
+r = requests.get(url)
+# print(json())
+# r.status_code
+
+# Passing parameters with URLs
+# e.g http://192.16.125.183/API_REST/request.php/get?key=val
+##
+# r = urllib.request.urlopen(url) # To open url for data response
+# content = r.read() # to read the data Content
+# data = json.loads(content.decode(("utf8"))
+# print(data)
+# print(data['type'])
+##
+# payload={'key1': 'value1', 'key2': 'value2'}
+
+#'''def response (url)
+# with urllib.request.urlopen(url)'''
# GET
r = requests.get(url)
# GET with params in URL
-r = requests.get(url, params=payload)
+#r = requests.get(url, params=payload)
-#GET with JSON
-r = requests.get('http://192.16.125.183/API_REST/request.php')
-r.json()
+# GET with JSON
+#r = requests.get('http://192.16.125.183/API_REST/request.php')
+# r.json()
# POST with form-encoded data
-r = requests.post(url, data=payload)
+# r = requests.post(url, data=payload)
-# POST with JSON
-
-import json
-r = requests.post(url, data=json.dumps(payload))
+# import json
+# r = requests.post(url, data=json.dumps(payload))
# Response, status etc
-#r.text #the text encoding guessed by Requests is used when you access to r.text
-
-r.status_code #check the status codes for the responses
+# r.text #the text encoding guessed by Requests is used when you access to r.text
+# r.status_code # check the status codes for the responses
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b