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 |