Matthewpan1 commited on
Commit
31620dd
·
verified ·
1 Parent(s): 8ae7c70

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +14 -1
README.md CHANGED
@@ -1,3 +1,16 @@
1
  ---
2
  license: apache-2.0
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  license: apache-2.0
3
+ ---
4
+ import requests
5
+ import shutil
6
+
7
+ data = 'https://api-ninjas.com'
8
+ fmt = 'png'
9
+ api_url = 'https://api.api-ninjas.com/v1/qrcode?data={}&format={}'.format(data, fmt)
10
+ response = requests.get(api_url, headers={'X-Api-Key': 'bYncBDuv5luV+rK7sqjemg==SAr2kbX5ZNqKmW8M
11
+ ', 'Accept': 'image/png'}, stream=True)
12
+ if response.status_code == requests.codes.ok:
13
+ with open('img.jpg', 'wb') as out_file:
14
+ shutil.copyfileobj(response.raw, out_file)
15
+ else:
16
+ print("Error:", response.status_code, response.text)