Skip to content

Instantly share code, notes, and snippets.

@caruccio
Last active December 16, 2015 11:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save caruccio/5427069 to your computer and use it in GitHub Desktop.
Save caruccio/5427069 to your computer and use it in GitHub Desktop.
Gists para o blog
from hammock import Hammock as Getup
username, password = 'mateus.caruccio@getupcloud.com', 'minha_senha'
getup = Getup('https://broker.getupcloud.com/broker/rest', auth=(username, password))
#
# Busca a lista de dominios (so temos um por enquanto)
#
domains = getup.domains.GET()
for domain in domains.json()['data']:
print domain['id']
# Saida:
# caruccio
#
# Busca a lista de aplicacoes do dominio
#
apps = getup.domains(domain['id']).applications.GET()
#
# Vamos mostrar algumas informacoes uteis sobre os apps
#
print '%-7s | %-10s | %-10s' % ('name', 'framework', 'url')
print '-' * 33
for app in apps.json()['data']:
print '%s: framework = %s, url = %s' % (app['name'], app['framework'], app['app_url'])
# Saida:
# name | framework | url
# ---------------------------------
# longrun: framework = php-5.3, url = http://longrun-caruccio.getup.io/
# blog: framework = php-5.3, url = http://blog-caruccio.getup.io/
>>> from hammock import Hammock as Getup
>>> getup = Getup('https://broker.getupcloud.com/broker/rest')
>>> res = getup.api.GET()
>>> res
<Response [200]>
>>> res.url
u'https://broker.getupcloud.com/broker/rest/api'
>>> res.status_code
200
>>> json = res.json()
>>> json
{u'status': u'ok', u'type': u'links', u'messages': [], u'version': u'1.3',...
>>> from hammock import Hammock as Github
>>> github = Github('https://github.com')
>>> github
https://github.com
>>> page = github.kadirpekel.hammock.GET()
>>> page
<Response [200]>
>>> page.url
u'https://github.com/kadirpekel/hammock'
>>> page.status_code
200
>>> page.text[0:30]
u' \n\n\n<!DOCTYPE html>\n<html>\n '
$ sudo pip install requests==0.13.6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment