{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "^" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ "\n" ] } ], "source": [ "from IPython.display import HTML, display\n", "\n", "display(HTML('''\n", "^'''))\n", "print('')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### PANORAMAS OF CINEMA online\n", "\n", "# // PANORAMA CREATOR\n", "\n", "v0.04" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# GLOBAL\n", "tag_http = 'http://poctag-env.eba-vjpstfpz.eu-central-1.elasticbeanstalk.com/tags'\n", "button_color = 'black' # #7d1b27\n", "print('')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## PANORAMA OF IMAGES" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### tags index" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "code_folding": [], "scrolled": false }, "outputs": [], "source": [ "import requests\n", "import ipywidgets as widgets\n", "\n", "this_request = tag_http+'?action=GET_ALL_TAGS'\n", "r = requests.get(this_request).json()['body']\n", "for e in sorted(r):\n", " print(e, end=' . ')\n", " \n", "def get_tags(event):\n", " clear_output()\n", "\n", " this_request = tag_http+'?action=GET_ALL_TAGS'\n", " r = requests.get(this_request).json()['body']\n", " for e in sorted(r):\n", " print(e, end=' . ')\n", " \n", " display(refresh_tags_button)\n", " \n", "refresh_tags_button = widgets.Button(description=\"refresh tags\", button_style='info')\n", "refresh_tags_button.style.button_color = button_color\n", "display(refresh_tags_button)\n", "refresh_tags_button.on_click(get_tags)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "print ('\\n')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### users index" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "code_folding": [], "scrolled": true }, "outputs": [], "source": [ "this_request = tag_http+'?action=GET_ALL_USERS'\n", "r = requests.get(this_request).json()['body']\n", "for e in sorted(r):\n", " print(e, end=' . ')\n", "\n", "def get_users(event):\n", " clear_output()\n", "\n", " this_request = tag_http+'?action=GET_ALL_USERS'\n", " r = requests.get(this_request).json()['body']\n", " for e in sorted(r):\n", " print(e, end=' . ')\n", " \n", " display(refresh_users_button)\n", "\n", " \n", "refresh_users_button = widgets.Button(description=\"refresh users\", button_style='info')\n", "refresh_users_button.style.button_color = button_color\n", "display(refresh_users_button)\n", "refresh_users_button.on_click(get_users)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "print ('\\n')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### > type a tag and/or user" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from IPython.display import clear_output\n", "from ipywidgets import interactive\n", "\n", "def getUser(user):\n", " return\n", "\n", "def getTag(tag):\n", " return\n", "\n", "def refresh(event):\n", " clear_output()\n", " display(w_tag)\n", " display(w_user)\n", " display(add_refresh_button)\n", " \n", " global this_user, this_tag\n", " this_user = w_user.kwargs['user']\n", " this_tag = w_tag.kwargs['tag']\n", " \n", " if len(this_user) > 0 and len(this_tag) > 0:\n", " this_request = tag_http+'?action=GET_FRAMES_USER_TAG&tag=%s&user=%s'%(this_tag,this_user)\n", " my_frames_tag = requests.get(this_request).json()\n", " this_length = len(my_frames_tag['body'])\n", " print (this_length, 'images to render')\n", " elif len(this_user) > 0 and len(this_tag) == 0:\n", " this_request = tag_http+'?action=GET_FRAMES_USER&user=%s'%(this_user)\n", " my_frames_tag = requests.get(this_request).json()\n", " this_length = len(my_frames_tag['body'])\n", " print (this_length, 'images to render')\n", " this_tags = set([ f['tag'] for f in my_frames_tag['body'] ])\n", " print (this_user, 'is talking about . ', end='')\n", " for e in sorted(this_tags): print(e, end=' . ')\n", " elif len(this_user) == 0 and len(this_tag) > 0:\n", " this_request = tag_http+'?action=GET_FRAMES_TAG&tag=%s'%(this_tag)\n", " my_frames_tag = requests.get(this_request).json()\n", " this_length = len(my_frames_tag['body'])\n", " print (this_length, 'images to render')\n", " this_users = set([ f['user'] for f in my_frames_tag['body'] ])\n", " print (this_tag, 'is talked about by . ', end='')\n", " for e in sorted(this_users): print(e, end=' . ')\n", " else:\n", " print ('type a user name and/or a tag')\n", "\n", "w_user = interactive(getUser, user='')\n", "w_tag = interactive(getTag, tag='')\n", "\n", "add_refresh_button = widgets.Button(description=\"refresh\", button_style='info')\n", "add_refresh_button.style.button_color = button_color\n", "add_refresh_button.on_click(refresh)\n", "\n", "display(w_tag)\n", "display(w_user)\n", "display(add_refresh_button)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "print ('\\n')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### > select your options" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "code_folding": [], "scrolled": false }, "outputs": [], "source": [ "#\n", "def getType(panorama, orientation, square, resolution):\n", " return\n", "\n", "def getSize(size):\n", " return \n", "\n", "# BUTTON EVENT\n", "def make_request(event):\n", " clear_output()\n", " display(ui2)\n", " display(ui1)\n", " display(request_panorama_button)\n", "\n", " this_size = size.kwargs['size']\n", " this_type = panorama.value\n", " this_square = square.value\n", " this_contour = 'no'\n", " this_resolution = resolution.value\n", " \n", " my_orientation = orientation.value\n", " if my_orientation == '[ ]': this_orientation = 'square'\n", " else: this_orientation = my_orientation\n", "\n", " this_query = 'http://poccreatepanorama-env.eba-upy2qcn6.eu-central-1.elasticbeanstalk.com/panorama?'\n", " if this_type: this_query = this_query+'type=%s'%this_type\n", " if this_user: this_query = this_query+'&user=%s'%this_user\n", " if this_tag: this_query = this_query+'&tag=%s'%this_tag\n", " if this_orientation: this_query = this_query+'&orientation=%s'%this_orientation\n", " if this_contour: this_query = this_query+'&images_contour=%s'%this_contour\n", " if this_square: this_query = this_query+'&images_square=%s'%this_square\n", " if this_size: this_query = this_query+'&grid=%s'%this_size\n", " if this_resolution: this_query = this_query+'&resolution=%s'%this_resolution\n", " \n", " # make request\n", " html_doc = requests.get(this_query)\n", " #print (this_query)\n", " \n", " from bs4 import BeautifulSoup\n", " soup = BeautifulSoup(html_doc.text, 'html.parser')\n", " my_panorama = soup.a.text\n", " if 'https://' in my_panorama: pass\n", " else: print (my_panorama)\n", "\n", " from IPython.display import Image\n", " display( Image(url=my_panorama) )\n", "\n", "panorama = widgets.RadioButtons( options=['atlas','dreams'], value='atlas', description='type' )\n", "orientation = widgets.RadioButtons( options=['horizontal','vertical','[ ]'], value='horizontal', description='orientation', disabled=False )\n", "square = widgets.RadioButtons( options=['no', 'yes'], value='no', description='square imgs' )\n", "# grid / resolution box\n", "resolution = widgets.RadioButtons( options=['low', 'high'], value='low', description='resolution' )\n", "size = interactive(getSize, size='3,2')\n", "#size_box = widgets.VBox([resolution, size])\n", "# arrange in boxes\n", "ui1 = widgets.HBox([panorama, orientation, square, resolution])\n", "ui2 = widgets.HBox([size])\n", "out = widgets.interactive_output(getType, {'panorama': panorama, 'orientation':orientation, 'square':square,\n", " 'resolution': resolution})\n", "\n", "display(ui2)\n", "display(ui1)\n", "\n", "request_panorama_button = widgets.Button(description=\"create panorama\", button_style='info')\n", "request_panorama_button.style.button_color = button_color\n", "request_panorama_button.on_click(make_request)\n", "display(request_panorama_button)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "print('\\n', '\\n', '\\n', '\\n', '\\n')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "ETH Zurich       Department of Architecture       Chair for Digital Architectonics       2021" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "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.9" } }, "nbformat": 4, "nbformat_minor": 4 }