You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1267 lines
645 KiB
Plaintext

{
"cells": [
{
"cell_type": "markdown",
"id": "8d5fd4da-995d-4304-adcf-2464e0187053",
"metadata": {},
"source": [
"# Learning how to walk while cat-walking ~ demo app\n",
"Hello this is a demo for the SI16 API and website from XPUB. Trying to document everything so it is not OBSCURE. Feel free to improve anything!\n",
"\n",
"The folder structure follows this scheme: \n",
"- In the ```root``` folder there is the notebook (this file) that runs the Flask application. \n",
"- The ```templates``` folder is the default one from Flask with the HTML templates. \n",
"- In the ```notebooks``` folder there are the files with the basic functions and their documentation in the format of notebook. \n",
"- In the ```projects``` folder there are the folders of the subgroup projects. We can put the files and materials of each project in there as well as the html pages etc. Each project should have also an ```documentation.md``` file with the info of the work. \n",
"- In the ```static``` folder there are all the static files such as css stylesheets, fonts, images, javascript files, etc. They are organized in specific sub-folders so we dont get messy \n",
"- In the ```contents``` folder there are all the markdown files with the text contents for the website. Description of the projects, about, colophon, manifesto, research etc. Each file contains the text and can include some metadata of our choice. Look at the about.md for an example "
]
},
{
"cell_type": "markdown",
"id": "1213eab7-5ca7-4cd9-8d1b-4f625f961899",
"metadata": {},
"source": [
"## Import\n",
"Here we import all the modules we need for making the app working."
]
},
{
"cell_type": "code",
"execution_count": 14,
"id": "b90f82e6-09b3-432d-9c02-596a4ca84e2f",
"metadata": {},
"outputs": [],
"source": [
"# to work with files in folder \n",
"import os\n",
"\n",
"# to create the Flask app\n",
"from flask import Flask, render_template, request, url_for, redirect, jsonify, abort\n",
"\n",
"# to import text contents and metadata from markdown files\n",
"from flaskext.markdown import Markdown\n",
"import frontmatter\n",
"\n",
"# to cast string arguments into the required types\n",
"from pydoc import locate\n",
"\n",
"# to work with notebooks\n",
"#\n",
"# to import notebook files\n",
"import nbimporter\n",
"nbimporter.options['only_defs'] = False\n",
"import importlib\n",
"\n",
"# to read and execute the content of notebooks\n",
"import nbformat\n",
"from nbconvert import HTMLExporter, MarkdownExporter\n",
"from nbconvert.preprocessors import ExecutePreprocessor\n",
"\n",
"# not sure about this is in the nbconvert documentation\n",
"from traitlets.config import Config\n",
"\n"
]
},
{
"cell_type": "markdown",
"id": "7c1bd05b-bc9c-4ac3-9654-61b2b17b0248",
"metadata": {},
"source": [
"## Functions\n",
"Here we define the functions for the logic of the backend and the API "
]
},
{
"cell_type": "code",
"execution_count": 15,
"id": "8fe33b07-3f37-4cab-8729-7919d053ba00",
"metadata": {},
"outputs": [],
"source": [
"def filenames(folder):\n",
" ''' Read all the functions in a folder '''\n",
" names = []\n",
" for entry in os.scandir(folder):\n",
" # add to the list only proper files\n",
" if entry.is_file(follow_symlinks=False):\n",
" # remove the extension from the filename\n",
" names.append(os.path.splitext(entry.name)[0])\n",
" return names"
]
},
{
"cell_type": "code",
"execution_count": 16,
"id": "73ece514-5247-4e89-b6a4-5afcf46f2afd",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"['vernacular_map', 'text_file_to_blob', 'shout', 'reverse', 'cocktail_generator', 'blob_to_excerpts_list', 'mashup', 'repeat', 'highlight_map', 'individual_map', 'bridge', 'add_target_info', 'area_map', 'input-back-to-text', 'target_map', 'ghost_map', 'html_tag']\n"
]
}
],
"source": [
"# example: print the file inside the notebooks folder\n",
"print(filenames('./notebooks'))"
]
},
{
"cell_type": "code",
"execution_count": 17,
"id": "b122207c-7ed7-4522-9b2f-018414d0f9fd",
"metadata": {},
"outputs": [],
"source": [
"def dirnames(folder):\n",
" ''' Return all the folders in a folder '''\n",
" names = []\n",
" for entry in os.scandir(folder):\n",
" # add to the list only proper files\n",
" if not entry.name.startswith('.') and entry.is_dir():\n",
" # remove the extension from the filename\n",
" names.append(entry.name)\n",
" return names"
]
},
{
"cell_type": "code",
"execution_count": 18,
"id": "cd82bfbf-2f51-4caf-bfec-443aa2ba5112",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"['etc', 'replace', 'map']\n"
]
}
],
"source": [
"print(dirnames('./projects'))"
]
},
{
"cell_type": "code",
"execution_count": 19,
"id": "f76b4396-2f11-4e9d-92bf-d20a884d30a1",
"metadata": {},
"outputs": [],
"source": [
"# not really sure about this file -> module -> function thing! \n",
"# could someone help pls ? \n",
"def get_function(name, folder):\n",
" ''' Dynamic import a function from a folder '''\n",
"# try: \n",
" file = __import__(f'{folder}.{name}')\n",
" module = getattr(file, name)\n",
" function = getattr(module, name)\n",
"# except AttributeError or ModuleNotFoundError:\n",
"# file = importlib.import_module(f'{folder}.{name}')\n",
"# function = getattr(file, name)\n",
" return function"
]
},
{
"cell_type": "code",
"execution_count": 20,
"id": "7639cbfd-3f42-45e9-a201-1d87cbc88d00",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"HelloHello\n",
"Saaaaaluuuuut\n"
]
}
],
"source": [
"# example: try a couple of functions from the notebooks folder\n",
"rep = get_function('repeat', 'notebooks')\n",
"print(rep('Hello'))\n",
"\n",
"sh = get_function('shout','notebooks')\n",
"print(sh('Salut'))\n",
"\n",
"# sc = get_function('scream', 'notebooks')\n",
"# print(sc('Buenos dias'))"
]
},
{
"cell_type": "code",
"execution_count": 21,
"id": "d8c41597-5273-4a90-be8b-341b16b6e78f",
"metadata": {},
"outputs": [],
"source": [
"def get_function_info(function):\n",
" ''' Extract info from a function '''\n",
" name = function.__name__\n",
" description = function.__doc__\n",
" parameters = []\n",
" output = ''\n",
"\n",
" # TODO: default values \n",
" \n",
" # populate a list of tuple with patameter, type\n",
" for param in function.__annotations__.keys():\n",
" if param == 'return':\n",
" output = function.__annotations__[param].__name__\n",
" if param != 'return':\n",
" parameters.append((param, function.__annotations__[param].__name__))\n",
" \n",
" return(name, description, parameters, output)"
]
},
{
"cell_type": "code",
"execution_count": 22,
"id": "4925d9f1-9718-4407-84c7-8749aad365a8",
"metadata": {},
"outputs": [],
"source": [
"def print_info(function):\n",
" ''' Print the info of a function nicely '''\n",
" name, description, parameters, output = get_function_info(function)\n",
" \n",
" # very important feature\n",
" from kaomoji.kaomoji import Kaomoji\n",
" kao = Kaomoji()\n",
" \n",
" header = f'----------{kao.create()}'\n",
" footer = '-' * len(header)\n",
" \n",
" print(header)\n",
" print(name)\n",
" print(description)\n",
" print('Input:')\n",
" for param, tp in parameters:\n",
" print(f' {param}, of type {tp}')\n",
" print(f'Returns a {output}')\n",
" print(footer)"
]
},
{
"cell_type": "code",
"execution_count": 23,
"id": "baa72939-3853-49bf-b426-77fc041590ab",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"----------(^ヮ☆)\n",
"repeat\n",
"Repeat a string for a specified number of times\n",
"Input:\n",
" text, of type str\n",
" times, of type int\n",
"Returns a str\n",
"-----------------\n"
]
}
],
"source": [
"print_info(rep)"
]
},
{
"cell_type": "code",
"execution_count": 24,
"id": "a4e67147-8f76-4d85-8d5b-b458a9b08ce6",
"metadata": {},
"outputs": [],
"source": [
"# optionally you can pass a boolean argument to execute the notebook before the export\n",
"# but it is a slow process so by default is not active\n",
"# TODO: markdown export instead of HTML ? \n",
"# TODO: extract images from base64\n",
"def get_notebook_contents(filename, execute = False):\n",
" ''' Export notebook contents as HTML. '''\n",
" with open(filename) as f:\n",
" nb = nbformat.read(f, as_version=4)\n",
" \n",
" if execute:\n",
" ep = ExecutePreprocessor(timeout=600, kernel_name='python3')\n",
" ep.preprocess(nb, {'metadata':{'path':'notebooks/'}})\n",
" \n",
" html_exporter = HTMLExporter() \n",
" html_exporter.template_name = 'basic' \n",
" (body, resources) = html_exporter.from_notebook_node(nb) \n",
" \n",
" return body\n",
" \n",
"# with open('executed_notebook.ipynb', 'w', encoding='utf-8') as f:\n",
"# nbformat.write(nb, f)"
]
},
{
"cell_type": "code",
"execution_count": 25,
"id": "a1a7edab-1cf0-4d8e-8d80-7b33704dd9ce",
"metadata": {
"scrolled": true,
"tags": []
},
"outputs": [
{
"data": {
"text/plain": [
"'<!DOCTYPE html>\\n<html>\\n<head><meta charset=\"utf-8\" />\\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\\n\\n<title>Notebook</title><script src=\"https://cdnjs.cloudflare.com/ajax/libs/require.js/2.1.10/require.min.js\"></script>\\n\\n\\n\\n\\n<style type=\"text/css\">\\n pre { line-height: 125%; }\\ntd.linenos .normal { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }\\nspan.linenos { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }\\ntd.linenos .special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }\\nspan.linenos.special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }\\n.highlight .hll { background-color: var(--jp-cell-editor-active-background) }\\n.highlight { background: var(--jp-cell-editor-background); color: var(--jp-mirror-editor-variable-color) }\\n.highlight .c { color: var(--jp-mirror-editor-comment-color); font-style: italic } /* Comment */\\n.highlight .err { color: var(--jp-mirror-editor-error-color) } /* Error */\\n.highlight .k { color: var(--jp-mirror-editor-keyword-color); font-weight: bold } /* Keyword */\\n.highlight .o { color: var(--jp-mirror-editor-operator-color); font-weight: bold } /* Operator */\\n.highlight .p { color: var(--jp-mirror-editor-punctuation-color) } /* Punctuation */\\n.highlight .ch { color: var(--jp-mirror-editor-comment-color); font-style: italic } /* Comment.Hashbang */\\n.highlight .cm { color: var(--jp-mirror-editor-comment-color); font-style: italic } /* Comment.Multiline */\\n.highlight .cp { color: var(--jp-mirror-editor-comment-color); font-style: italic } /* Comment.Preproc */\\n.highlight .cpf { color: var(--jp-mirror-editor-comment-color); font-style: italic } /* Comment.PreprocFile */\\n.highlight .c1 { color: var(--jp-mirror-editor-comment-color); font-style: italic } /* Comment.Single */\\n.highlight .cs { color: var(--jp-mirror-editor-comment-color); font-style: italic } /* Comment.Special */\\n.highlight .kc { color: var(--jp-mirror-editor-keyword-color); font-weight: bold } /* Keyword.Constant */\\n.highlight .kd { color: var(--jp-mirror-editor-keyword-color); font-weight: bold } /* Keyword.Declaration */\\n.highlight .kn { color: var(--jp-mirror-editor-keyword-color); font-weight: bold } /* Keyword.Namespace */\\n.highlight .kp { color: var(--jp-mirror-editor-keyword-color); font-weight: bold } /* Keyword.Pseudo */\\n.highlight .kr { color: var(--jp-mirror-editor-keyword-color); font-weight: bold } /* Keyword.Reserved */\\n.highlight .kt { color: var(--jp-mirror-editor-keyword-color); font-weight: bold } /* Keyword.Type */\\n.highlight .m { color: var(--jp-mirror-editor-number-color) } /* Literal.Number */\\n.highlight .s { color: var(--jp-mirror-editor-string-color) } /* Literal.String */\\n.highlight .ow { color: var(--jp-mirror-editor-operator-color); font-weight: bold } /* Operator.Word */\\n.highlight .w { color: var(--jp-mirror-editor-variable-color) } /* Text.Whitespace */\\n.highlight .mb { color: var(--jp-mirror-editor-number-color) } /* Literal.Number.Bin */\\n.highlight .mf { color: var(--jp-mirror-editor-number-color) } /* Literal.Number.Float */\\n.highlight .mh { color: var(--jp-mirror-editor-number-color) } /* Literal.Number.Hex */\\n.highlight .mi { color: var(--jp-mirror-editor-number-color) } /* Literal.Number.Integer */\\n.highlight .mo { color: var(--jp-mirror-editor-number-color) } /* Literal.Number.Oct */\\n.highlight .sa { color: var(--jp-mirror-editor-string-color) } /* Literal.String.Affix */\\n.highlight .sb { color: var(--jp-mirror-editor-string-color) } /* Literal.String.Backtick */\\n.highlight .sc { color: var(--jp-mirror-editor-string-color) } /* Literal.String.Char */\\n.highlight .dl { color: var(--jp-mirror-editor-string-color) } /* Literal.String.Delimiter */\\n.highlight .sd { color: var(--jp-mirror-editor-string-color) } /* Literal.String.Doc */\\n.highlight .s2 { color: var(--jp-mirror-editor-string-color) } /* Literal.String
]
},
"execution_count": 25,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"get_notebook_contents('./notebooks/repeat.ipynb')"
]
},
{
"cell_type": "code",
"execution_count": 26,
"id": "93fca26c-73b2-42b0-a08e-ca864744e7e2",
"metadata": {},
"outputs": [],
"source": [
"# EXPORT AS MARKDOWN\n",
"def get_notebook_md(filename, execute = False):\n",
" ''' Export notebook contents as Markdown. '''\n",
" with open(filename) as f:\n",
" nb = nbformat.read(f, as_version=4)\n",
" \n",
" if execute:\n",
" ep = ExecutePreprocessor(timeout=600, kernel_name='python3')\n",
" ep.preprocess(nb, {'metadata':{'path':'notebooks/'}})\n",
" \n",
" md_exporter = MarkdownExporter() \n",
" \n",
"# html_exporter.template_name = 'basic' \n",
" (body, resources) = md_exporter.from_notebook_node(nb) \n",
" \n",
" return body\n",
" \n",
"# with open('executed_notebook.ipynb', 'w', encoding='utf-8') as f:\n",
"# nbformat.write(nb, f)"
]
},
{
"cell_type": "code",
"execution_count": 28,
"id": "f51f6261-f4f6-4b9a-96ab-e92a6e93c2a3",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"# Repeat\n",
"Repeat a string for a specified number of times\n",
"\n",
"\n",
"```python\n",
"def repeat(text: str, times: int = 2) -> str:\n",
" \"\"\"Repeat a string for a specified number of times\"\"\"\n",
" return text * times\n",
"```\n",
"\n",
"![ara repeating itself](https://www.dienst.nl/sub/upload/images/1/30019_550.jpg)\n",
"\n",
"This function has many attractive qualities, but its ability to repeat human speech is one that makes it truly unique among other types of companion python functions and one that has ensured its popularity for generations. You are likely to find, though, that the function's talents for mimicry still pales in comparison to the fact that it is charming, engaging, and truly remarkable. Here is one of the most popular repeating function so that you can appreciate more about what it has to offer. It often says injuries to people and computers. \n",
"\n",
"## Examples\n",
"\n",
"The function takes a string as a parameter, and by default it repeats it twice. \n",
"\n",
"\n",
"```python\n",
"repeat('hello')\n",
"```\n",
"\n",
"\n",
"\n",
"\n",
" 'hellohello'\n",
"\n",
"\n",
"\n",
"Eventually with a second parameter you can specify how many times you want it to repeats. \n",
"\n",
"\n",
"```python\n",
"repeat('salut', 4)\n",
"```\n",
"\n",
"\n",
"\n",
"\n",
" 'salutsalutsalutsalut'\n",
"\n",
"\n",
"\n",
"\n",
"```python\n",
"\n",
"```\n",
"\n"
]
}
],
"source": [
"print(get_notebook_md('./notebooks/repeat.ipynb'))"
]
},
{
"cell_type": "code",
"execution_count": 15,
"id": "9debce59-d77c-4bae-b090-e4b78ffae43b",
"metadata": {},
"outputs": [],
"source": [
"def get_contents(filename, directory = './contents'):\n",
" ''' Return contents from a filename as frontmatter handler '''\n",
" with open(f\"{directory}/{filename}\", \"r\") as f:\n",
" content = frontmatter.load(f)\n",
" return content"
]
},
{
"cell_type": "code",
"execution_count": 16,
"id": "ae55a519-f12b-44b5-91c0-707bdaed6800",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"About\n",
"These are the info about SI16 - Learning how to walk while cat-walking\n",
"\n",
"Dear friend and online scroller,\n",
"Beloved internet user, \n",
"Dearest anonymous scroller binge watcher and human being IRL, \n",
"\n",
"![bibi](/soupboat/si16-app/static/img/bibi.jpg)\n",
"\n",
"Do you like cats? Fond of Walking? Never heard of Python? (No. Not the snake) \n",
"Great. \n",
"You're very welcome to check out our Special Issue 16 on vernacular language processing: Learning How to Walk while Cat-walking. It is about embracing vulnerability, sharing the clumsiness with little time and little technical knowledge in the form of a toolkit and encourage others to cat-walk with us.\n",
"\n",
"Our toolkit wants to mess around with language that creates relations of power in its structuring information, in its grammar rules, in its standard taxonomies, categories and tags, in its organizing data and shaping knowledge, in its legitimizing hierarchies in a dialogue between two or more people... |__(we could use the etc tool here heheh)__| in order to propose tools for a word based analysis grounded within a more vernacular and informal understanding of language as such. \n",
"\n",
"We decided to release the Special Issue 16 as an API (Application Programming Interfaces), the kind of protocol through which most of the internet we use functions, but remaining invisible, mysterious and somehow intangible. What is not always evident is that while facilitating the exchange of information between different software programs and systems, APIs often organise and serve data and knowledge, according to specific standards and purposes (mainly commercial). \n",
"\n",
"Our API wants to have a more critical and vernacular approach to such model of distribution, but don't worry if you didn't understand, we'll guide you through it while still trying to figure out what an API means ourselves. What we know for sure is that:\n",
"\n",
"we are confident, we are ambitious and we are failing a lot while learn\u0002ing how to walk while cat-walking. We want to legitimize failures and amateur practices outside the hierarchy of experience. We want to deconstruct those hierarchies taking care of each other in the process of learning, now between us, and then with you. We approach the text as a texture, a malleable clay tablet, a space for foreign input and extensive modifications, for cut-up and for collage, for collective agency and participation. We work to sort out several mean\u0002ings from the same text. Meanings with perspective and a common ground. We intend to blur our roles as authors, as users, and as public because this is an act of collective world building.\n"
]
}
],
"source": [
"# example: print the contents of the about file\n",
"test_about = get_contents('about.md')\n",
"\n",
"print(test_about['title'])\n",
"print(test_about['description'])\n",
"print()\n",
"print(test_about.content)"
]
},
{
"cell_type": "markdown",
"id": "a8c17569-b74e-48d1-86a9-ba1e6f61af1f",
"metadata": {},
"source": [
"## Flask App"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "30798f7b-671b-42d9-a343-eb713f513806",
"metadata": {
"tags": []
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
" * Serving Flask app '__main__' (lazy loading)\n",
" * Environment: production\n",
"\u001b[31m WARNING: This is a development server. Do not use it in a production deployment.\u001b[0m\n",
"\u001b[2m Use a production WSGI server instead.\u001b[0m\n",
" * Debug mode: off\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
" * Running on http://127.0.0.1:3130/ (Press CTRL+C to quit)\n",
"127.0.0.1 - - [08/Dec/2021 19:21:38] \"GET /si16-app/ HTTP/1.0\" 200 -\n",
"127.0.0.1 - - [08/Dec/2021 19:21:40] \"GET /si16-app/projects/ HTTP/1.0\" 200 -\n",
"127.0.0.1 - - [08/Dec/2021 19:21:43] \"GET /si16-app/functions/ HTTP/1.0\" 200 -\n",
"[2021-12-08 19:21:47,463] ERROR in app: Exception on /si16-app/functions/area_map/ [GET]\n",
"Traceback (most recent call last):\n",
" File \"/usr/local/lib/python3.7/dist-packages/flask/app.py\", line 2073, in wsgi_app\n",
" response = self.full_dispatch_request()\n",
" File \"/usr/local/lib/python3.7/dist-packages/flask/app.py\", line 1518, in full_dispatch_request\n",
" rv = self.handle_user_exception(e)\n",
" File \"/usr/local/lib/python3.7/dist-packages/flask/app.py\", line 1516, in full_dispatch_request\n",
" rv = self.dispatch_request()\n",
" File \"/usr/local/lib/python3.7/dist-packages/flask/app.py\", line 1502, in dispatch_request\n",
" return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)\n",
" File \"/tmp/ipykernel_9986/665664178.py\", line 76, in f_info\n",
" fx = get_function(function, notebooks)\n",
" File \"/tmp/ipykernel_9986/867254570.py\", line 6, in get_function\n",
" file = __import__(f'{folder}.{name}')\n",
" File \"<frozen importlib._bootstrap>\", line 983, in _find_and_load\n",
" File \"<frozen importlib._bootstrap>\", line 967, in _find_and_load_unlocked\n",
" File \"<frozen importlib._bootstrap>\", line 668, in _load_unlocked\n",
" File \"<frozen importlib._bootstrap>\", line 638, in _load_backward_compatible\n",
" File \"/usr/local/lib/python3.7/dist-packages/nbimporter.py\", line 110, in load_module\n",
" exec(codeobj, mod.__dict__)\n",
" File \"/var/www/html/si16-app/notebooks/area_map.ipynb\", line 4, in <module>\n",
" \"cell_type\": \"markdown\",\n",
" File \"/usr/lib/python3.7/urllib/request.py\", line 222, in urlopen\n",
" return opener.open(url, data, timeout)\n",
" File \"/usr/lib/python3.7/urllib/request.py\", line 531, in open\n",
" response = meth(req, response)\n",
" File \"/usr/lib/python3.7/urllib/request.py\", line 641, in http_response\n",
" 'http', request, response, code, msg, hdrs)\n",
" File \"/usr/lib/python3.7/urllib/request.py\", line 569, in error\n",
" return self._call_chain(*args)\n",
" File \"/usr/lib/python3.7/urllib/request.py\", line 503, in _call_chain\n",
" result = func(*args)\n",
" File \"/usr/lib/python3.7/urllib/request.py\", line 649, in http_error_default\n",
" raise HTTPError(req.full_url, code, msg, hdrs, fp)\n",
"urllib.error.HTTPError: HTTP Error 502: Bad Gateway\n",
"127.0.0.1 - - [08/Dec/2021 19:21:47] \"\u001b[35m\u001b[1mGET /si16-app/functions/area_map/ HTTP/1.0\u001b[0m\" 500 -\n",
"127.0.0.1 - - [08/Dec/2021 19:21:53] \"GET /si16-app/ HTTP/1.0\" 200 -\n",
"127.0.0.1 - - [08/Dec/2021 19:21:57] \"GET /si16-app/functions/ HTTP/1.0\" 200 -\n",
"127.0.0.1 - - [08/Dec/2021 19:22:00] \"GET /si16-app/functions/ HTTP/1.0\" 200 -\n",
"[2021-12-08 19:22:02,228] ERROR in app: Exception on /si16-app/functions/reverse/ [GET]\n",
"Traceback (most recent call last):\n",
" File \"/usr/local/lib/python3.7/dist-packages/flask/app.py\", line 2073, in wsgi_app\n",
" response = self.full_dispatch_request()\n",
" File \"/usr/local/lib/python3.7/dist-packages/flask/app.py\", line 1518, in full_dispatch_request\n",
" rv = self.handle_user_exception(e)\n",
" File \"/usr/local/lib/python3.7/dist-packages/flask/app.py\", line 1516, in full_dispatch_request\n",
" rv = self.dispatch_request()\n",
" File \"/usr/local/lib/python3.7/dist-packages/flask/app.py\", line 1502, in dispatch_request\n",
" return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)\n",
" File \"/tmp/ipykernel_9986/665664178.py\", line 76, in f_info\n",
" fx = get_function(function, notebooks)\n",
" File \"/tmp/ipykernel_9986/867254570.py\", line 6, in get_function\n",
" file = __import__(f'{folder}.{name}')\n",
" File \"<frozen importlib._bootstrap>\", line 983, in _find_and_load\n",
" File \"<frozen importlib._bootstrap>\", line 967, in _find_and_load_unlocked\n",
" File \"<frozen importlib._bootstrap>\", line 668, in _load_unlocked\n",
" File \"<frozen importlib._bootstrap>\", line 638, in _load_backward_compatible\n",
" File \"/usr/local/lib/python3.7/dist-packages/nbimporter.py\", line 110, in load_module\n",
" exec(codeobj, mod.__dict__)\n",
" File \"/var/www/html/si16-app/notebooks/reverse.ipynb\", line 1, in <module>\n",
" {\n",
" File \"/var/www/html/si16-app/notebooks/reverse.ipynb\", line 6, in reverse\n",
" \"metadata\": {},\n",
"TypeError: sequence item 0: expected str instance, Sentence found\n",
"127.0.0.1 - - [08/Dec/2021 19:22:02] \"\u001b[35m\u001b[1mGET /si16-app/functions/reverse/ HTTP/1.0\u001b[0m\" 500 -\n",
"127.0.0.1 - - [08/Dec/2021 19:22:05] \"GET /si16-app/functions/shout/ HTTP/1.0\" 200 -\n",
"127.0.0.1 - - [08/Dec/2021 20:06:26] \"GET /si16-app/functions/ HTTP/1.0\" 200 -\n",
"[2021-12-08 20:06:28,827] ERROR in app: Exception on /si16-app/functions/cocktail_generator/ [GET]\n",
"Traceback (most recent call last):\n",
" File \"/usr/local/lib/python3.7/dist-packages/flask/app.py\", line 2073, in wsgi_app\n",
" response = self.full_dispatch_request()\n",
" File \"/usr/local/lib/python3.7/dist-packages/flask/app.py\", line 1518, in full_dispatch_request\n",
" rv = self.handle_user_exception(e)\n",
" File \"/usr/local/lib/python3.7/dist-packages/flask/app.py\", line 1516, in full_dispatch_request\n",
" rv = self.dispatch_request()\n",
" File \"/usr/local/lib/python3.7/dist-packages/flask/app.py\", line 1502, in dispatch_request\n",
" return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)\n",
" File \"/tmp/ipykernel_9986/665664178.py\", line 76, in f_info\n",
" fx = get_function(function, notebooks)\n",
" File \"/tmp/ipykernel_9986/867254570.py\", line 6, in get_function\n",
" file = __import__(f'{folder}.{name}')\n",
" File \"<frozen importlib._bootstrap>\", line 983, in _find_and_load\n",
" File \"<frozen importlib._bootstrap>\", line 967, in _find_and_load_unlocked\n",
" File \"<frozen importlib._bootstrap>\", line 668, in _load_unlocked\n",
" File \"<frozen importlib._bootstrap>\", line 638, in _load_backward_compatible\n",
" File \"/usr/local/lib/python3.7/dist-packages/nbimporter.py\", line 110, in load_module\n",
" exec(codeobj, mod.__dict__)\n",
" File \"/var/www/html/si16-app/notebooks/cocktail_generator.ipynb\", line 1, in <module>\n",
" {\n",
"NameError: name 'repeat' is not defined\n",
"127.0.0.1 - - [08/Dec/2021 20:06:28] \"\u001b[35m\u001b[1mGET /si16-app/functions/cocktail_generator/ HTTP/1.0\u001b[0m\" 500 -\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*\n",
"*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*\n",
"* *\n",
"* CATWALKING WITH ALCOHOL *\n",
"* *\n",
"* 2021-12-08 21:06:28 *\n",
"* *\n",
"*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*\n",
"*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*\n",
"\n",
"\n",
"\n",
"2 oz RUM\n",
"\n",
"150 ml TONIC WATER\n",
"\n",
"1 oz LEMON JUICE\n",
"\n",
"0.5 oz MAPLE SIRUP\n",
"\n",
"1 SLICE CUCUMBER\n",
"\n",
"1 UMBRELLA\n",
"\n",
"\n",
"*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*\n",
"\n",
"EXTRA: SALTED CORN\n",
"\n",
"*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*\n",
"\n",
"\n",
"\n",
" ___, \n",
" '._.'\\ \n",
" _____/'-.\\ \n",
" | / | \n",
" |~~~/~~| \n",
" \\ () / \n",
" '.__.' \n",
" || \n",
" _||_ \n",
" `----` \n",
"\n",
"\n",
"THANKS FOR COMING TO OUR LAUNCH!\n",
"\n",
" (*(*(*(*(*.(*.*).*)*)*)*)*)*)\n",
"\n",
"\n",
"*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*\n",
"*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*\n",
"\n",
"\n",
"\n",
"\n",
"\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[2021-12-08 20:06:33,187] ERROR in app: Exception on /si16-app/functions/cocktail_generator/ [GET]\n",
"Traceback (most recent call last):\n",
" File \"/usr/local/lib/python3.7/dist-packages/flask/app.py\", line 2073, in wsgi_app\n",
" response = self.full_dispatch_request()\n",
" File \"/usr/local/lib/python3.7/dist-packages/flask/app.py\", line 1518, in full_dispatch_request\n",
" rv = self.handle_user_exception(e)\n",
" File \"/usr/local/lib/python3.7/dist-packages/flask/app.py\", line 1516, in full_dispatch_request\n",
" rv = self.dispatch_request()\n",
" File \"/usr/local/lib/python3.7/dist-packages/flask/app.py\", line 1502, in dispatch_request\n",
" return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)\n",
" File \"/tmp/ipykernel_9986/665664178.py\", line 76, in f_info\n",
" fx = get_function(function, notebooks)\n",
" File \"/tmp/ipykernel_9986/867254570.py\", line 7, in get_function\n",
" module = getattr(file, name)\n",
"AttributeError: module 'notebooks' has no attribute 'cocktail_generator'\n",
"127.0.0.1 - - [08/Dec/2021 20:06:33] \"\u001b[35m\u001b[1mGET /si16-app/functions/cocktail_generator/ HTTP/1.0\u001b[0m\" 500 -\n",
"127.0.0.1 - - [08/Dec/2021 20:06:35] \"GET /si16-app/functions/repeat/ HTTP/1.0\" 200 -\n",
"127.0.0.1 - - [08/Dec/2021 20:06:46] \"GET /si16-app/api/repeat/?text=%2Cjchvja&times=5 HTTP/1.0\" 200 -\n",
"[2021-12-08 20:27:24,058] ERROR in app: Exception on /si16-app/functions/cocktail_generator/ [GET]\n",
"Traceback (most recent call last):\n",
" File \"/usr/local/lib/python3.7/dist-packages/flask/app.py\", line 2073, in wsgi_app\n",
" response = self.full_dispatch_request()\n",
" File \"/usr/local/lib/python3.7/dist-packages/flask/app.py\", line 1518, in full_dispatch_request\n",
" rv = self.handle_user_exception(e)\n",
" File \"/usr/local/lib/python3.7/dist-packages/flask/app.py\", line 1516, in full_dispatch_request\n",
" rv = self.dispatch_request()\n",
" File \"/usr/local/lib/python3.7/dist-packages/flask/app.py\", line 1502, in dispatch_request\n",
" return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)\n",
" File \"/tmp/ipykernel_9986/665664178.py\", line 76, in f_info\n",
" fx = get_function(function, notebooks)\n",
" File \"/tmp/ipykernel_9986/867254570.py\", line 7, in get_function\n",
" module = getattr(file, name)\n",
"AttributeError: module 'notebooks' has no attribute 'cocktail_generator'\n",
"127.0.0.1 - - [08/Dec/2021 20:27:24] \"\u001b[35m\u001b[1mGET /si16-app/functions/cocktail_generator/ HTTP/1.0\u001b[0m\" 500 -\n",
"127.0.0.1 - - [08/Dec/2021 20:27:26] \"GET /si16-app/ HTTP/1.0\" 200 -\n",
"127.0.0.1 - - [08/Dec/2021 20:27:33] \"GET /si16-app/functions/ HTTP/1.0\" 200 -\n",
"[2021-12-08 20:27:35,691] ERROR in app: Exception on /si16-app/functions/area_map/ [GET]\n",
"Traceback (most recent call last):\n",
" File \"/usr/local/lib/python3.7/dist-packages/flask/app.py\", line 2073, in wsgi_app\n",
" response = self.full_dispatch_request()\n",
" File \"/usr/local/lib/python3.7/dist-packages/flask/app.py\", line 1518, in full_dispatch_request\n",
" rv = self.handle_user_exception(e)\n",
" File \"/usr/local/lib/python3.7/dist-packages/flask/app.py\", line 1516, in full_dispatch_request\n",
" rv = self.dispatch_request()\n",
" File \"/usr/local/lib/python3.7/dist-packages/flask/app.py\", line 1502, in dispatch_request\n",
" return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)\n",
" File \"/tmp/ipykernel_9986/665664178.py\", line 76, in f_info\n",
" fx = get_function(function, notebooks)\n",
" File \"/tmp/ipykernel_9986/867254570.py\", line 7, in get_function\n",
" module = getattr(file, name)\n",
"AttributeError: module 'notebooks' has no attribute 'area_map'\n",
"127.0.0.1 - - [08/Dec/2021 20:27:35] \"\u001b[35m\u001b[1mGET /si16-app/functions/area_map/ HTTP/1.0\u001b[0m\" 500 -\n",
"127.0.0.1 - - [08/Dec/2021 20:27:39] \"GET /si16-app/functions/repeat/ HTTP/1.0\" 200 -\n",
"127.0.0.1 - - [08/Dec/2021 20:27:41] \"GET /si16-app/functions/vernacular_map/ HTTP/1.0\" 200 -\n",
"127.0.0.1 - - [08/Dec/2021 20:27:49] \"GET /si16-app/functions/highlight_map/ HTTP/1.0\" 200 -\n",
"127.0.0.1 - - [08/Dec/2021 20:27:53] \"GET /si16-app/functions/individual_map/ HTTP/1.0\" 200 -\n",
"[2021-12-08 20:27:56,210] ERROR in app: Exception on /si16-app/functions/area_map/ [GET]\n",
"Traceback (most recent call last):\n",
" File \"/usr/local/lib/python3.7/dist-packages/flask/app.py\", line 2073, in wsgi_app\n",
" response = self.full_dispatch_request()\n",
" File \"/usr/local/lib/python3.7/dist-packages/flask/app.py\", line 1518, in full_dispatch_request\n",
" rv = self.handle_user_exception(e)\n",
" File \"/usr/local/lib/python3.7/dist-packages/flask/app.py\", line 1516, in full_dispatch_request\n",
" rv = self.dispatch_request()\n",
" File \"/usr/local/lib/python3.7/dist-packages/flask/app.py\", line 1502, in dispatch_request\n",
" return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)\n",
" File \"/tmp/ipykernel_9986/665664178.py\", line 76, in f_info\n",
" fx = get_function(function, notebooks)\n",
" File \"/tmp/ipykernel_9986/867254570.py\", line 7, in get_function\n",
" module = getattr(file, name)\n",
"AttributeError: module 'notebooks' has no attribute 'area_map'\n",
"127.0.0.1 - - [08/Dec/2021 20:27:56] \"\u001b[35m\u001b[1mGET /si16-app/functions/area_map/ HTTP/1.0\u001b[0m\" 500 -\n",
"127.0.0.1 - - [08/Dec/2021 20:27:59] \"GET /si16-app/functions/target_map/ HTTP/1.0\" 200 -\n",
"[2021-12-08 20:28:05,706] ERROR in app: Exception on /si16-app/functions/ghost_map/ [GET]\n",
"Traceback (most recent call last):\n",
" File \"/usr/local/lib/python3.7/dist-packages/flask/app.py\", line 2073, in wsgi_app\n",
" response = self.full_dispatch_request()\n",
" File \"/usr/local/lib/python3.7/dist-packages/flask/app.py\", line 1518, in full_dispatch_request\n",
" rv = self.handle_user_exception(e)\n",
" File \"/usr/local/lib/python3.7/dist-packages/flask/app.py\", line 1516, in full_dispatch_request\n",
" rv = self.dispatch_request()\n",
" File \"/usr/local/lib/python3.7/dist-packages/flask/app.py\", line 1502, in dispatch_request\n",
" return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)\n",
" File \"/tmp/ipykernel_9986/665664178.py\", line 76, in f_info\n",
" fx = get_function(function, notebooks)\n",
" File \"/tmp/ipykernel_9986/867254570.py\", line 6, in get_function\n",
" file = __import__(f'{folder}.{name}')\n",
" File \"<frozen importlib._bootstrap>\", line 983, in _find_and_load\n",
" File \"<frozen importlib._bootstrap>\", line 967, in _find_and_load_unlocked\n",
" File \"<frozen importlib._bootstrap>\", line 668, in _load_unlocked\n",
" File \"<frozen importlib._bootstrap>\", line 638, in _load_backward_compatible\n",
" File \"/usr/local/lib/python3.7/dist-packages/nbimporter.py\", line 110, in load_module\n",
" exec(codeobj, mod.__dict__)\n",
" File \"/var/www/html/si16-app/notebooks/ghost_map.ipynb\", line 4, in <module>\n",
" \"cell_type\": \"markdown\",\n",
" File \"/usr/lib/python3.7/urllib/request.py\", line 222, in urlopen\n",
" return opener.open(url, data, timeout)\n",
" File \"/usr/lib/python3.7/urllib/request.py\", line 531, in open\n",
" response = meth(req, response)\n",
" File \"/usr/lib/python3.7/urllib/request.py\", line 641, in http_response\n",
" 'http', request, response, code, msg, hdrs)\n",
" File \"/usr/lib/python3.7/urllib/request.py\", line 569, in error\n",
" return self._call_chain(*args)\n",
" File \"/usr/lib/python3.7/urllib/request.py\", line 503, in _call_chain\n",
" result = func(*args)\n",
" File \"/usr/lib/python3.7/urllib/request.py\", line 649, in http_error_default\n",
" raise HTTPError(req.full_url, code, msg, hdrs, fp)\n",
"urllib.error.HTTPError: HTTP Error 502: Bad Gateway\n",
"127.0.0.1 - - [08/Dec/2021 20:28:05] \"\u001b[35m\u001b[1mGET /si16-app/functions/ghost_map/ HTTP/1.0\u001b[0m\" 500 -\n",
"[2021-12-08 20:28:08,257] ERROR in app: Exception on /si16-app/functions/html_tag/ [GET]\n",
"Traceback (most recent call last):\n",
" File \"/usr/local/lib/python3.7/dist-packages/flask/app.py\", line 2073, in wsgi_app\n",
" response = self.full_dispatch_request()\n",
" File \"/usr/local/lib/python3.7/dist-packages/flask/app.py\", line 1518, in full_dispatch_request\n",
" rv = self.handle_user_exception(e)\n",
" File \"/usr/local/lib/python3.7/dist-packages/flask/app.py\", line 1516, in full_dispatch_request\n",
" rv = self.dispatch_request()\n",
" File \"/usr/local/lib/python3.7/dist-packages/flask/app.py\", line 1502, in dispatch_request\n",
" return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)\n",
" File \"/tmp/ipykernel_9986/665664178.py\", line 76, in f_info\n",
" fx = get_function(function, notebooks)\n",
" File \"/tmp/ipykernel_9986/867254570.py\", line 6, in get_function\n",
" file = __import__(f'{folder}.{name}')\n",
" File \"<frozen importlib._bootstrap>\", line 983, in _find_and_load\n",
" File \"<frozen importlib._bootstrap>\", line 967, in _find_and_load_unlocked\n",
" File \"<frozen importlib._bootstrap>\", line 668, in _load_unlocked\n",
" File \"<frozen importlib._bootstrap>\", line 638, in _load_backward_compatible\n",
" File \"/usr/local/lib/python3.7/dist-packages/nbimporter.py\", line 110, in load_module\n",
" exec(codeobj, mod.__dict__)\n",
" File \"/var/www/html/si16-app/notebooks/html_tag.ipynb\", line 4, in <module>\n",
" \"cell_type\": \"markdown\",\n",
" File \"/usr/lib/python3.7/urllib/request.py\", line 222, in urlopen\n",
" return opener.open(url, data, timeout)\n",
" File \"/usr/lib/python3.7/urllib/request.py\", line 531, in open\n",
" response = meth(req, response)\n",
" File \"/usr/lib/python3.7/urllib/request.py\", line 641, in http_response\n",
" 'http', request, response, code, msg, hdrs)\n",
" File \"/usr/lib/python3.7/urllib/request.py\", line 569, in error\n",
" return self._call_chain(*args)\n",
" File \"/usr/lib/python3.7/urllib/request.py\", line 503, in _call_chain\n",
" result = func(*args)\n",
" File \"/usr/lib/python3.7/urllib/request.py\", line 649, in http_error_default\n",
" raise HTTPError(req.full_url, code, msg, hdrs, fp)\n",
"urllib.error.HTTPError: HTTP Error 502: Bad Gateway\n",
"127.0.0.1 - - [08/Dec/2021 20:28:08] \"\u001b[35m\u001b[1mGET /si16-app/functions/html_tag/ HTTP/1.0\u001b[0m\" 500 -\n",
"[2021-12-08 20:28:10,772] ERROR in app: Exception on /si16-app/functions/cocktail_generator/ [GET]\n",
"Traceback (most recent call last):\n",
" File \"/usr/local/lib/python3.7/dist-packages/flask/app.py\", line 2073, in wsgi_app\n",
" response = self.full_dispatch_request()\n",
" File \"/usr/local/lib/python3.7/dist-packages/flask/app.py\", line 1518, in full_dispatch_request\n",
" rv = self.handle_user_exception(e)\n",
" File \"/usr/local/lib/python3.7/dist-packages/flask/app.py\", line 1516, in full_dispatch_request\n",
" rv = self.dispatch_request()\n",
" File \"/usr/local/lib/python3.7/dist-packages/flask/app.py\", line 1502, in dispatch_request\n",
" return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)\n",
" File \"/tmp/ipykernel_9986/665664178.py\", line 76, in f_info\n",
" fx = get_function(function, notebooks)\n",
" File \"/tmp/ipykernel_9986/867254570.py\", line 7, in get_function\n",
" module = getattr(file, name)\n",
"AttributeError: module 'notebooks' has no attribute 'cocktail_generator'\n",
"127.0.0.1 - - [08/Dec/2021 20:28:10] \"\u001b[35m\u001b[1mGET /si16-app/functions/cocktail_generator/ HTTP/1.0\u001b[0m\" 500 -\n",
"127.0.0.1 - - [08/Dec/2021 20:28:38] \"GET /si16-app/functions/ HTTP/1.0\" 200 -\n",
"127.0.0.1 - - [08/Dec/2021 20:28:39] \"GET /si16-app/functions/ HTTP/1.0\" 200 -\n",
"[2021-12-08 20:28:43,774] ERROR in app: Exception on /si16-app/functions/cocktail_generator/ [GET]\n",
"Traceback (most recent call last):\n",
" File \"/usr/local/lib/python3.7/dist-packages/flask/app.py\", line 2073, in wsgi_app\n",
" response = self.full_dispatch_request()\n",
" File \"/usr/local/lib/python3.7/dist-packages/flask/app.py\", line 1518, in full_dispatch_request\n",
" rv = self.handle_user_exception(e)\n",
" File \"/usr/local/lib/python3.7/dist-packages/flask/app.py\", line 1516, in full_dispatch_request\n",
" rv = self.dispatch_request()\n",
" File \"/usr/local/lib/python3.7/dist-packages/flask/app.py\", line 1502, in dispatch_request\n",
" return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)\n",
" File \"/tmp/ipykernel_9986/665664178.py\", line 76, in f_info\n",
" fx = get_function(function, notebooks)\n",
" File \"/tmp/ipykernel_9986/867254570.py\", line 7, in get_function\n",
" module = getattr(file, name)\n",
"AttributeError: module 'notebooks' has no attribute 'cocktail_generator'\n",
"127.0.0.1 - - [08/Dec/2021 20:28:43] \"\u001b[35m\u001b[1mGET /si16-app/functions/cocktail_generator/ HTTP/1.0\u001b[0m\" 500 -\n",
"[2021-12-08 20:29:15,253] ERROR in app: Exception on /si16-app/functions/cocktail_generator/ [GET]\n",
"Traceback (most recent call last):\n",
" File \"/usr/local/lib/python3.7/dist-packages/flask/app.py\", line 2073, in wsgi_app\n",
" response = self.full_dispatch_request()\n",
" File \"/usr/local/lib/python3.7/dist-packages/flask/app.py\", line 1518, in full_dispatch_request\n",
" rv = self.handle_user_exception(e)\n",
" File \"/usr/local/lib/python3.7/dist-packages/flask/app.py\", line 1516, in full_dispatch_request\n",
" rv = self.dispatch_request()\n",
" File \"/usr/local/lib/python3.7/dist-packages/flask/app.py\", line 1502, in dispatch_request\n",
" return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)\n",
" File \"/tmp/ipykernel_9986/665664178.py\", line 76, in f_info\n",
" fx = get_function(function, notebooks)\n",
" File \"/tmp/ipykernel_9986/867254570.py\", line 7, in get_function\n",
" module = getattr(file, name)\n",
"AttributeError: module 'notebooks' has no attribute 'cocktail_generator'\n",
"127.0.0.1 - - [08/Dec/2021 20:29:15] \"\u001b[35m\u001b[1mGET /si16-app/functions/cocktail_generator/ HTTP/1.0\u001b[0m\" 500 -\n",
"[2021-12-08 20:29:17,751] ERROR in app: Exception on /si16-app/functions/cocktail_generator/ [GET]\n",
"Traceback (most recent call last):\n",
" File \"/usr/local/lib/python3.7/dist-packages/flask/app.py\", line 2073, in wsgi_app\n",
" response = self.full_dispatch_request()\n",
" File \"/usr/local/lib/python3.7/dist-packages/flask/app.py\", line 1518, in full_dispatch_request\n",
" rv = self.handle_user_exception(e)\n",
" File \"/usr/local/lib/python3.7/dist-packages/flask/app.py\", line 1516, in full_dispatch_request\n",
" rv = self.dispatch_request()\n",
" File \"/usr/local/lib/python3.7/dist-packages/flask/app.py\", line 1502, in dispatch_request\n",
" return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)\n",
" File \"/tmp/ipykernel_9986/665664178.py\", line 76, in f_info\n",
" fx = get_function(function, notebooks)\n",
" File \"/tmp/ipykernel_9986/867254570.py\", line 7, in get_function\n",
" module = getattr(file, name)\n",
"AttributeError: module 'notebooks' has no attribute 'cocktail_generator'\n",
"127.0.0.1 - - [08/Dec/2021 20:29:17] \"\u001b[35m\u001b[1mGET /si16-app/functions/cocktail_generator/ HTTP/1.0\u001b[0m\" 500 -\n",
"[2021-12-08 20:29:18,966] ERROR in app: Exception on /si16-app/functions/cocktail_generator/ [GET]\n",
"Traceback (most recent call last):\n",
" File \"/usr/local/lib/python3.7/dist-packages/flask/app.py\", line 2073, in wsgi_app\n",
" response = self.full_dispatch_request()\n",
" File \"/usr/local/lib/python3.7/dist-packages/flask/app.py\", line 1518, in full_dispatch_request\n",
" rv = self.handle_user_exception(e)\n",
" File \"/usr/local/lib/python3.7/dist-packages/flask/app.py\", line 1516, in full_dispatch_request\n",
" rv = self.dispatch_request()\n",
" File \"/usr/local/lib/python3.7/dist-packages/flask/app.py\", line 1502, in dispatch_request\n",
" return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)\n",
" File \"/tmp/ipykernel_9986/665664178.py\", line 76, in f_info\n",
" fx = get_function(function, notebooks)\n",
" File \"/tmp/ipykernel_9986/867254570.py\", line 7, in get_function\n",
" module = getattr(file, name)\n",
"AttributeError: module 'notebooks' has no attribute 'cocktail_generator'\n",
"127.0.0.1 - - [08/Dec/2021 20:29:18] \"\u001b[35m\u001b[1mGET /si16-app/functions/cocktail_generator/ HTTP/1.0\u001b[0m\" 500 -\n",
"[2021-12-08 20:30:16,613] ERROR in app: Exception on /si16-app/functions/cocktail_generator/ [GET]\n",
"Traceback (most recent call last):\n",
" File \"/usr/local/lib/python3.7/dist-packages/flask/app.py\", line 2073, in wsgi_app\n",
" response = self.full_dispatch_request()\n",
" File \"/usr/local/lib/python3.7/dist-packages/flask/app.py\", line 1518, in full_dispatch_request\n",
" rv = self.handle_user_exception(e)\n",
" File \"/usr/local/lib/python3.7/dist-packages/flask/app.py\", line 1516, in full_dispatch_request\n",
" rv = self.dispatch_request()\n",
" File \"/usr/local/lib/python3.7/dist-packages/flask/app.py\", line 1502, in dispatch_request\n",
" return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)\n",
" File \"/tmp/ipykernel_9986/665664178.py\", line 76, in f_info\n",
" fx = get_function(function, notebooks)\n",
" File \"/tmp/ipykernel_9986/867254570.py\", line 7, in get_function\n",
" module = getattr(file, name)\n",
"AttributeError: module 'notebooks' has no attribute 'cocktail_generator'\n",
"127.0.0.1 - - [08/Dec/2021 20:30:16] \"\u001b[35m\u001b[1mGET /si16-app/functions/cocktail_generator/ HTTP/1.0\u001b[0m\" 500 -\n",
"[2021-12-08 20:30:18,488] ERROR in app: Exception on /si16-app/functions/cocktail_generator/ [GET]\n",
"Traceback (most recent call last):\n",
" File \"/usr/local/lib/python3.7/dist-packages/flask/app.py\", line 2073, in wsgi_app\n",
" response = self.full_dispatch_request()\n",
" File \"/usr/local/lib/python3.7/dist-packages/flask/app.py\", line 1518, in full_dispatch_request\n",
" rv = self.handle_user_exception(e)\n",
" File \"/usr/local/lib/python3.7/dist-packages/flask/app.py\", line 1516, in full_dispatch_request\n",
" rv = self.dispatch_request()\n",
" File \"/usr/local/lib/python3.7/dist-packages/flask/app.py\", line 1502, in dispatch_request\n",
" return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)\n",
" File \"/tmp/ipykernel_9986/665664178.py\", line 76, in f_info\n",
" fx = get_function(function, notebooks)\n",
" File \"/tmp/ipykernel_9986/867254570.py\", line 7, in get_function\n",
" module = getattr(file, name)\n",
"AttributeError: module 'notebooks' has no attribute 'cocktail_generator'\n",
"127.0.0.1 - - [08/Dec/2021 20:30:18] \"\u001b[35m\u001b[1mGET /si16-app/functions/cocktail_generator/ HTTP/1.0\u001b[0m\" 500 -\n",
"127.0.0.1 - - [08/Dec/2021 20:30:41] \"GET /si16-app/ HTTP/1.0\" 200 -\n",
"127.0.0.1 - - [08/Dec/2021 20:30:42] \"GET /si16-app/functions/ HTTP/1.0\" 200 -\n",
"[2021-12-08 20:30:44,432] ERROR in app: Exception on /si16-app/functions/cocktail_generator/ [GET]\n",
"Traceback (most recent call last):\n",
" File \"/usr/local/lib/python3.7/dist-packages/flask/app.py\", line 2073, in wsgi_app\n",
" response = self.full_dispatch_request()\n",
" File \"/usr/local/lib/python3.7/dist-packages/flask/app.py\", line 1518, in full_dispatch_request\n",
" rv = self.handle_user_exception(e)\n",
" File \"/usr/local/lib/python3.7/dist-packages/flask/app.py\", line 1516, in full_dispatch_request\n",
" rv = self.dispatch_request()\n",
" File \"/usr/local/lib/python3.7/dist-packages/flask/app.py\", line 1502, in dispatch_request\n",
" return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)\n",
" File \"/tmp/ipykernel_9986/665664178.py\", line 76, in f_info\n",
" fx = get_function(function, notebooks)\n",
" File \"/tmp/ipykernel_9986/867254570.py\", line 7, in get_function\n",
" module = getattr(file, name)\n",
"AttributeError: module 'notebooks' has no attribute 'cocktail_generator'\n",
"127.0.0.1 - - [08/Dec/2021 20:30:44] \"\u001b[35m\u001b[1mGET /si16-app/functions/cocktail_generator/ HTTP/1.0\u001b[0m\" 500 -\n",
"[2021-12-08 20:30:46,387] ERROR in app: Exception on /si16-app/functions/cocktail_generator/ [GET]\n",
"Traceback (most recent call last):\n",
" File \"/usr/local/lib/python3.7/dist-packages/flask/app.py\", line 2073, in wsgi_app\n",
" response = self.full_dispatch_request()\n",
" File \"/usr/local/lib/python3.7/dist-packages/flask/app.py\", line 1518, in full_dispatch_request\n",
" rv = self.handle_user_exception(e)\n",
" File \"/usr/local/lib/python3.7/dist-packages/flask/app.py\", line 1516, in full_dispatch_request\n",
" rv = self.dispatch_request()\n",
" File \"/usr/local/lib/python3.7/dist-packages/flask/app.py\", line 1502, in dispatch_request\n",
" return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)\n",
" File \"/tmp/ipykernel_9986/665664178.py\", line 76, in f_info\n",
" fx = get_function(function, notebooks)\n",
" File \"/tmp/ipykernel_9986/867254570.py\", line 7, in get_function\n",
" module = getattr(file, name)\n",
"AttributeError: module 'notebooks' has no attribute 'cocktail_generator'\n",
"127.0.0.1 - - [08/Dec/2021 20:30:46] \"\u001b[35m\u001b[1mGET /si16-app/functions/cocktail_generator/ HTTP/1.0\u001b[0m\" 500 -\n",
"[2021-12-08 20:30:47,458] ERROR in app: Exception on /si16-app/functions/cocktail_generator/ [GET]\n",
"Traceback (most recent call last):\n",
" File \"/usr/local/lib/python3.7/dist-packages/flask/app.py\", line 2073, in wsgi_app\n",
" response = self.full_dispatch_request()\n",
" File \"/usr/local/lib/python3.7/dist-packages/flask/app.py\", line 1518, in full_dispatch_request\n",
" rv = self.handle_user_exception(e)\n",
" File \"/usr/local/lib/python3.7/dist-packages/flask/app.py\", line 1516, in full_dispatch_request\n",
" rv = self.dispatch_request()\n",
" File \"/usr/local/lib/python3.7/dist-packages/flask/app.py\", line 1502, in dispatch_request\n",
" return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)\n",
" File \"/tmp/ipykernel_9986/665664178.py\", line 76, in f_info\n",
" fx = get_function(function, notebooks)\n",
" File \"/tmp/ipykernel_9986/867254570.py\", line 7, in get_function\n",
" module = getattr(file, name)\n",
"AttributeError: module 'notebooks' has no attribute 'cocktail_generator'\n",
"127.0.0.1 - - [08/Dec/2021 20:30:47] \"\u001b[35m\u001b[1mGET /si16-app/functions/cocktail_generator/ HTTP/1.0\u001b[0m\" 500 -\n",
"[2021-12-08 20:30:48,412] ERROR in app: Exception on /si16-app/functions/cocktail_generator/ [GET]\n",
"Traceback (most recent call last):\n",
" File \"/usr/local/lib/python3.7/dist-packages/flask/app.py\", line 2073, in wsgi_app\n",
" response = self.full_dispatch_request()\n",
" File \"/usr/local/lib/python3.7/dist-packages/flask/app.py\", line 1518, in full_dispatch_request\n",
" rv = self.handle_user_exception(e)\n",
" File \"/usr/local/lib/python3.7/dist-packages/flask/app.py\", line 1516, in full_dispatch_request\n",
" rv = self.dispatch_request()\n",
" File \"/usr/local/lib/python3.7/dist-packages/flask/app.py\", line 1502, in dispatch_request\n",
" return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)\n",
" File \"/tmp/ipykernel_9986/665664178.py\", line 76, in f_info\n",
" fx = get_function(function, notebooks)\n",
" File \"/tmp/ipykernel_9986/867254570.py\", line 7, in get_function\n",
" module = getattr(file, name)\n",
"AttributeError: module 'notebooks' has no attribute 'cocktail_generator'\n",
"127.0.0.1 - - [08/Dec/2021 20:30:48] \"\u001b[35m\u001b[1mGET /si16-app/functions/cocktail_generator/ HTTP/1.0\u001b[0m\" 500 -\n",
"[2021-12-08 20:31:01,247] ERROR in app: Exception on /si16-app/functions/cocktail_generator/ [GET]\n",
"Traceback (most recent call last):\n",
" File \"/usr/local/lib/python3.7/dist-packages/flask/app.py\", line 2073, in wsgi_app\n",
" response = self.full_dispatch_request()\n",
" File \"/usr/local/lib/python3.7/dist-packages/flask/app.py\", line 1518, in full_dispatch_request\n",
" rv = self.handle_user_exception(e)\n",
" File \"/usr/local/lib/python3.7/dist-packages/flask/app.py\", line 1516, in full_dispatch_request\n",
" rv = self.dispatch_request()\n",
" File \"/usr/local/lib/python3.7/dist-packages/flask/app.py\", line 1502, in dispatch_request\n",
" return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)\n",
" File \"/tmp/ipykernel_9986/665664178.py\", line 76, in f_info\n",
" fx = get_function(function, notebooks)\n",
" File \"/tmp/ipykernel_9986/867254570.py\", line 7, in get_function\n",
" module = getattr(file, name)\n",
"AttributeError: module 'notebooks' has no attribute 'cocktail_generator'\n",
"127.0.0.1 - - [08/Dec/2021 20:31:01] \"\u001b[35m\u001b[1mGET /si16-app/functions/cocktail_generator/ HTTP/1.0\u001b[0m\" 500 -\n",
"[2021-12-08 20:31:02,386] ERROR in app: Exception on /si16-app/functions/cocktail_generator/ [GET]\n",
"Traceback (most recent call last):\n",
" File \"/usr/local/lib/python3.7/dist-packages/flask/app.py\", line 2073, in wsgi_app\n",
" response = self.full_dispatch_request()\n",
" File \"/usr/local/lib/python3.7/dist-packages/flask/app.py\", line 1518, in full_dispatch_request\n",
" rv = self.handle_user_exception(e)\n",
" File \"/usr/local/lib/python3.7/dist-packages/flask/app.py\", line 1516, in full_dispatch_request\n",
" rv = self.dispatch_request()\n",
" File \"/usr/local/lib/python3.7/dist-packages/flask/app.py\", line 1502, in dispatch_request\n",
" return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)\n",
" File \"/tmp/ipykernel_9986/665664178.py\", line 76, in f_info\n",
" fx = get_function(function, notebooks)\n",
" File \"/tmp/ipykernel_9986/867254570.py\", line 7, in get_function\n",
" module = getattr(file, name)\n",
"AttributeError: module 'notebooks' has no attribute 'cocktail_generator'\n",
"127.0.0.1 - - [08/Dec/2021 20:31:02] \"\u001b[35m\u001b[1mGET /si16-app/functions/cocktail_generator/ HTTP/1.0\u001b[0m\" 500 -\n",
"[2021-12-08 20:31:03,557] ERROR in app: Exception on /si16-app/functions/cocktail_generator/ [GET]\n",
"Traceback (most recent call last):\n",
" File \"/usr/local/lib/python3.7/dist-packages/flask/app.py\", line 2073, in wsgi_app\n",
" response = self.full_dispatch_request()\n",
" File \"/usr/local/lib/python3.7/dist-packages/flask/app.py\", line 1518, in full_dispatch_request\n",
" rv = self.handle_user_exception(e)\n",
" File \"/usr/local/lib/python3.7/dist-packages/flask/app.py\", line 1516, in full_dispatch_request\n",
" rv = self.dispatch_request()\n",
" File \"/usr/local/lib/python3.7/dist-packages/flask/app.py\", line 1502, in dispatch_request\n",
" return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)\n",
" File \"/tmp/ipykernel_9986/665664178.py\", line 76, in f_info\n",
" fx = get_function(function, notebooks)\n",
" File \"/tmp/ipykernel_9986/867254570.py\", line 7, in get_function\n",
" module = getattr(file, name)\n",
"AttributeError: module 'notebooks' has no attribute 'cocktail_generator'\n",
"127.0.0.1 - - [08/Dec/2021 20:31:03] \"\u001b[35m\u001b[1mGET /si16-app/functions/cocktail_generator/ HTTP/1.0\u001b[0m\" 500 -\n",
"127.0.0.1 - - [08/Dec/2021 20:31:05] \"GET /si16-app/ HTTP/1.0\" 200 -\n",
"127.0.0.1 - - [08/Dec/2021 20:31:07] \"GET /si16-app/functions/ HTTP/1.0\" 200 -\n",
"[2021-12-08 20:31:08,112] ERROR in app: Exception on /si16-app/functions/cocktail_generator/ [GET]\n",
"Traceback (most recent call last):\n",
" File \"/usr/local/lib/python3.7/dist-packages/flask/app.py\", line 2073, in wsgi_app\n",
" response = self.full_dispatch_request()\n",
" File \"/usr/local/lib/python3.7/dist-packages/flask/app.py\", line 1518, in full_dispatch_request\n",
" rv = self.handle_user_exception(e)\n",
" File \"/usr/local/lib/python3.7/dist-packages/flask/app.py\", line 1516, in full_dispatch_request\n",
" rv = self.dispatch_request()\n",
" File \"/usr/local/lib/python3.7/dist-packages/flask/app.py\", line 1502, in dispatch_request\n",
" return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)\n",
" File \"/tmp/ipykernel_9986/665664178.py\", line 76, in f_info\n",
" fx = get_function(function, notebooks)\n",
" File \"/tmp/ipykernel_9986/867254570.py\", line 7, in get_function\n",
" module = getattr(file, name)\n",
"AttributeError: module 'notebooks' has no attribute 'cocktail_generator'\n",
"127.0.0.1 - - [08/Dec/2021 20:31:08] \"\u001b[35m\u001b[1mGET /si16-app/functions/cocktail_generator/ HTTP/1.0\u001b[0m\" 500 -\n"
]
}
],
"source": [
"# create flask application\n",
"app = Flask(__name__)\n",
"Markdown(app)\n",
"\n",
"base_url = \"si16-app\"\n",
"notebooks = \"notebooks\"\n",
"projects = \"projects\"\n",
"\n",
"\n",
"# For specific pages we can build and link dedicated templates\n",
"\n",
"\n",
"# Homepage\n",
"@app.route(f\"/{base_url}/\")\n",
"def home_page():\n",
" return render_template(\"home.html\")\n",
"\n",
"\n",
"# About Page\n",
"@app.route(f\"/{base_url}/about/\")\n",
"def about_page():\n",
" about = get_contents('about.md')\n",
" return render_template(\"about.html\", title = about['title'], description = about['description'], contents=about.content)\n",
"\n",
"# Terms of Service page\n",
"@app.route(f\"/{base_url}/tos/\")\n",
"def tos_page():\n",
" about = get_contents('tos.md')\n",
" return render_template(\"tos.html\", title = about['title'], description = about['description'], contents=about.content)\n",
"\n",
"# For generic pages we can include a common template and change only the contents\n",
"@app.route(f\"/{base_url}/<slug>/\")\n",
"def dynamic_page(slug = None):\n",
" try:\n",
" page = get_contents(f\"{slug}.md\").to_dict()\n",
" # page is a dictionary that contains: \n",
" # - all the attributes in the markdown file (ex: title, description, soup, etc)\n",
" # - the content of the md in the property 'content'\n",
" # in this way we can access those frontmatter attributes in jinja simply using the variables title, description, soup, etc\n",
" return render_template(\"page.html\", **page)\n",
" except FileNotFoundError:\n",
" # TODO: a proper not found page\n",
" return render_template('404.html')\n",
"\n",
"\n",
"\n",
"# List of projects\n",
"@app.route(f\"/{base_url}/projects/\")\n",
"def projects_list():\n",
" # get a list of the functions from the notebooks folder\n",
" projects = dirnames(\"./projects\")\n",
"\n",
" # generate a link to each function\n",
" return render_template(\"projects.html\", projects=projects)\n",
"\n",
"\n",
"# Single project\n",
"@app.route(f\"/{base_url}/projects/<project>/\")\n",
"def p_info(project = None):\n",
" try:\n",
" page = get_contents(\"documentation.md\", f\"./{projects}/{project}\").to_dict()\n",
" return render_template(\"project.html\", **page)\n",
" except FileNotFoundError:\n",
" return render_template('404.html')\n",
" \n",
"\n",
" \n",
"# List of functions\n",
"@app.route(f\"/{base_url}/functions/\")\n",
"def functions_list():\n",
" # get a list of the functions from the notebooks folder\n",
" functions = filenames(\"./notebooks\")\n",
"\n",
" # generate a link to each function\n",
" return render_template(\"functions.html\", functions=functions)\n",
"\n",
"\n",
"# Single Function page\n",
"@app.route(f\"/{base_url}/functions/<function>/\")\n",
"def f_info(function=None):\n",
" if function in filenames(f\"./{notebooks}\"):\n",
" fx = get_function(function, notebooks)\n",
" name, description, parameters, output = get_function_info(fx)\n",
"\n",
" # executing a notebook takes a lot of time mmm should we just send them without the results of the examples? or save it executed?\n",
" documentation = get_notebook_contents(f\"./{notebooks}/{function}.ipynb\")\n",
"\n",
" return render_template(\"function.html\", name=name, description=description, parameters=parameters, output=output, documentation=documentation)\n",
"\n",
" # TODO: meaningful error code return\n",
" else:\n",
" return render_template('404.html')\n",
"\n",
" \n",
" \n",
"# Function API page\n",
"\n",
"@app.route(f\"/{base_url}/api/<function>/\")\n",
"def f_api(function=None):\n",
" if function in filenames(f\"./{notebooks}\"):\n",
"\n",
" fx = get_function(function, notebooks)\n",
" name, description, parameters, output = get_function_info(fx)\n",
"\n",
" query_params = []\n",
" for param, tp in parameters:\n",
" a = request.args.get(param)\n",
" # cast the type of the argument to the type that the function requires\n",
" tp = locate(tp)\n",
" a = tp(a)\n",
" query_params.append(a)\n",
" return fx(*query_params)\n",
"\n",
" # TODO: meaningful error code return\n",
" return \"mmmm there is no function with this name sorry\"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"# Error handlers!\n",
"@app.errorhandler(400)\n",
"def error_400(e):\n",
" # bad request or invalid url\n",
" return render_template('400.html'), 400\n",
"\n",
"@app.errorhandler(403)\n",
"def error_403(e):\n",
" # forbidden (for invalid key) for evemt mode when it's not the 17th of the month\n",
" return render_template('403.html'), 403\n",
"\n",
"@app.errorhandler(404)\n",
"def error_404(e):\n",
" # page not found\n",
" return render_template('404.html'), 404\n",
"\n",
"@app.errorhandler(500)\n",
"def error_500(e):\n",
" # internal server error\n",
" return render_template('500.html'), 500\n",
"\n",
"@app.errorhandler(502)\n",
"def error_502(e):\n",
" # bad gateaway\n",
" return render_template('502.html'), 502\n",
"\n",
"@app.errorhandler(503)\n",
"def error_503(e):\n",
" # service temporarily unavailable, for secret breaks\n",
" return render_template('503.html'), 503\n",
"\n",
"@app.errorhandler(504)\n",
"def error_503(e):\n",
" # ???????? gateway timeout shall we put it?????\n",
" return render_template('504.html'), 504\n",
"app.run(port=\"3130\")\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "47c97ec9-9707-4896-8595-ac70aa5e6199",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"id": "96f5dbe2-36a2-4b2c-9e5b-99eef418fcda",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"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.3"
}
},
"nbformat": 4,
"nbformat_minor": 5
}