Skip to content

Instantly share code, notes, and snippets.

@chucknado

chucknado/app.py

Last active Aug 30, 2016
Embed
What would you like to do?
Bottle app for simple server-side Zendesk app (https://support.zendesk.com/hc/en-us/articles/226176327)
from bottle import route, run, template, request, response, static_file
import requests
@route('/sidebar')
def send_iframe_html():
qs = request.query_string
response.set_cookie('my_app_params', qs)
return template('start', qs=qs)
@route('/list')
def show_tasks():
access_token = "your_access_token"
header = {'Authorization': 'Bearer {}'.format(access_token)}
url = 'https://app.asana.com/api/1.0/projects/your_project_id/tasks'
r = requests.get(url, headers=header)
if r.status_code == 200:
tasks = r.json()
return template('list_tasks', list=tasks['data'])
else:
msg = 'Problem with the request: {} {}'.format(r.status_code, r.reason)
qs = request.get_cookie('my_app_params')
return template('start', qs=qs, error_msg=msg)
@route('/js/<filename>')
def send_js(filename):
return static_file(filename, root='static/js')
run(host='localhost', port=8080, debug=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment