Skip to content

Instantly share code, notes, and snippets.

@psychemedia
Created August 6, 2018 16:54
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 psychemedia/7a61d67c5b8314150e0f5d042cc532a4 to your computer and use it in GitHub Desktop.
Save psychemedia/7a61d67c5b8314150e0f5d042cc532a4 to your computer and use it in GitHub Desktop.
SImple Jupyter powered notebook api
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import json"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"REQUEST = json.dumps({\n",
" 'path' : {},\n",
" 'args' : {}\n",
"})"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# GET /\n",
"\n",
"print(\"It's alive...\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# GET /hello/:name\n",
"request = json.loads(REQUEST)\n",
"name = request['path'].get('name')\n",
"\n",
"print('Hello there, {}'.format(name))"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.0"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment