Created
August 30, 2013 23:21
-
-
Save edhiley/6395213 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
{ | |
"metadata": { | |
"name": "Url Template" | |
}, | |
"nbformat": 3, | |
"nbformat_minor": 0, | |
"worksheets": [ | |
{ | |
"cells": [ | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": "# url template\n\nusing uritemplate" | |
}, | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": "from uritemplate import expand\nreport_template = \"http://{domain}/report/summary?startTime={startTime}&endTime={endTime}\"\nurl = expand(report_template, \n {\n \"domain\": \"foo.com\", \n \"startTime\": \"atime\", \n \"endTime\": \"btime\"})\nassert url == \"http://foo.com/report/summary?startTime=atime&endTime=btime\"", | |
"language": "python", | |
"metadata": {}, | |
"outputs": [], | |
"prompt_number": 18 | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": "Or just ..." | |
}, | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": "report_template = \"http://{domain}/report/summary?startTime={startTime}&endTime={endTime}\"\nreport_template.format(\n domain=\"foo.com\", \n startTime=\"atime\", \n endTime=\"btime\")\nassert url == \"http://foo.com/report/summary?startTime=atime&endTime=btime\"", | |
"language": "python", | |
"metadata": {}, | |
"outputs": [] | |
} | |
], | |
"metadata": {} | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment