Created
January 9, 2020 19:45
-
-
Save gracemcgrath/345c144f1717bf896ed78ea08b999540 to your computer and use it in GitHub Desktop.
Winterns2020: sample python API requests
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from flask import Flask, render_template | |
import requests, json | |
app = Flask(__name__) | |
@app.route("/api-explorer", methods=['GET', 'POST']) | |
def makeRequest(): | |
response = requests.post('https://api-ssl.bitly.com/v4/bitlinks', json={"long_url":"https://dev.bitly.com/v4/#operation/getBitlinksByGroup"},headers={'Authorization': 'Bearer <ACCESS_TOKEN>'}) | |
print("My new bitlink: " + json.loads(response.text)["link"]) | |
response2 = requests.get('https://api-ssl.bitly.com/v4/user', headers={'Authorization': '<ACCESS_TOKEN>'}) | |
print("My group_guid response code: ", (response2.status_code)) | |
return render_template('app.html') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment