|
|
--- |
|
|
license: apache-2.0 |
|
|
--- |
|
|
import requests |
|
|
import shutil |
|
|
|
|
|
data = 'https://api-ninjas.com' |
|
|
fmt = 'png' |
|
|
api_url = 'https://api.api-ninjas.com/v1/qrcode?data={}&format={}'.format(data, fmt) |
|
|
response = requests.get(api_url, headers={'X-Api-Key': 'bYncBDuv5luV+rK7sqjemg==SAr2kbX5ZNqKmW8M |
|
|
', 'Accept': 'image/png'}, stream=True) |
|
|
if response.status_code == requests.codes.ok: |
|
|
with open('img.jpg', 'wb') as out_file: |
|
|
shutil.copyfileobj(response.raw, out_file) |
|
|
else: |
|
|
print("Error:", response.status_code, response.text) |