· 6 years ago · Mar 18, 2020, 03:22 AM
1https://www.geeksforgeeks.org/get-post-requests-using-python/
2GeeksforGeeksGeeksforGeeks
3GET and POST requests using Python - GeeksforGeeks
4A Computer Science portal for geeks. It contains well written, well thought and well explained computer science and programming articles, quizzes and practice/competitive programming/company interview Questions.
5Dec 7th, 2016
6
7
8
9
10
112:55
12https://www.geeksforgeeks.org/get-post-requests-using-python/
132:55
14# importing the requests library
15import requests
16# defining the api-endpoint
17API_ENDPOINT = "http://pastebin.com/api/api_post.php"
18# your API key here
19API_KEY = "XXXXXXXXXXXXXXXXX"
20# your source code here
21source_code = '''
22print("Hello, world!")
23a = 1
24b = 2
25print(a + b)
26'''
27# data to be sent to api
28data = {'api_dev_key':API_KEY,
29 'api_option':'paste',
30 'api_paste_code':source_code,
31 'api_paste_format':'python'}
32# sending post request and saving response as response object
33r = requests.post(url = API_ENDPOINT, data = data)
34# extracting response text
35pastebin_url = r.text
36print("The pastebin URL is:%s"%pastebin_url)
37
38
39
40
41
42
43files = {'file': open('vidName.mov', 'rb')}
44response = requests.post(url, files=files)