def github(): name = request.args.get('name', None) if not name: return 'Please provide Github username `name` query param', 400 access_token = request.args.get('access_token', None) github = Github(name, access_token) try: repo = request.args.get('repo', None) if not repo: return jsonify(github.repos()) typ = request.args.get('type', 'branches') # or commits if typ == 'branches': return jsonify(github.branches(repo)) elif typ == 'commits': return jsonify(github.commits(repo)) else: return 'Please provide `type` query params. Optional are `branches`, `commits`', 400 except GithubError as exc: return 'Invalid params passed. ' + str(exc), 400