konstantinostef/personal_assistant
0
1{2 "cells": [3 {4 "cell_type": "code",5 "execution_count": 1,6 "id": "88bcf062-6cf2-4099-9252-b1f7485610c9",7 "metadata": {},8 "outputs": [9 {10 "name": "stdout",11 "output_type": "stream",12 "text": [13 "* Running on local URL: http://127.0.0.1:7860\n",14 "\n",15 "To create a public link, set `share=True` in `launch()`.\n"16 ]17 },18 {19 "data": {20 "text/html": [21 "<div><iframe src=\"http://127.0.0.1:7860/\" width=\"100%\" height=\"500\" allow=\"autoplay; camera; microphone; clipboard-read; clipboard-write;\" frameborder=\"0\" allowfullscreen></iframe></div>"22 ],23 "text/plain": [24 "<IPython.core.display.HTML object>"25 ]26 },27 "metadata": {},28 "output_type": "display_data"29 },30 {31 "data": {32 "text/plain": []33 },34 "execution_count": 1,35 "metadata": {},36 "output_type": "execute_result"37 }38 ],39 "source": [40 "import gradio as gr\n",41 "import os\n",42 "\n",43 "html_file_path = \"fullcalendar3.html\"\n",44 "\n",45 "def load_html():\n",46 " if os.path.exists(html_file_path):\n",47 " with open(html_file_path, \"r\", encoding='utf-8') as file:\n",48 " content = file.read()\n",49 " # Wrap the content in an iframe to isolate it\n",50 " return f'<iframe srcdoc=\"{content.replace(chr(34), chr(39))}\" style=\"width: 100%; height: 800px; border: none;\"></iframe>'\n",51 " return \"<p>File not found</p>\"\n",52 "\n",53 "def refresh():\n",54 " return load_html()\n",55 "\n",56 "with gr.Blocks() as demo:\n",57 " with gr.Row():\n",58 " refresh_btn = gr.Button(\"Refresh Calendar\")\n",59 " with gr.Row():\n",60 " iframe = gr.HTML(load_html())\n",61 " \n",62 " refresh_btn.click(refresh, outputs=iframe)\n",63 "\n",64 "demo.launch()"65 ]66 }67 ],68 "metadata": {69 "kernelspec": {70 "display_name": "Python 3 (ipykernel)",71 "language": "python",72 "name": "python3"73 },74 "language_info": {75 "codemirror_mode": {76 "name": "ipython",77 "version": 378 },79 "file_extension": ".py",80 "mimetype": "text/x-python",81 "name": "python",82 "nbconvert_exporter": "python",83 "pygments_lexer": "ipython3",84 "version": "3.11.11"85 }86 },87 "nbformat": 4,88 "nbformat_minor": 589}90 