{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "source": [
    "import requests \r\n",
    "\r\n",
    "from flask import Flask\r\n",
    "from flask import render_template\r\n",
    "from flask import request\r\n",
    "from werkzeug.wrappers import Request, Response\r\n",
    "\r\n",
    "def shutdown_server():\r\n",
    "    func = request.environ.get(\"werkzeug.server.shutdown\")\r\n",
    "    if func is None:\r\n",
    "        raise RuntimeError(\"Not running with the Werkzeug Server\")\r\n",
    "    func()\r\n",
    "    \r\n",
    "app = Flask(__name__)\r\n",
    "@app.route(\"/\")\r\n",
    "def index():\r\n",
    "    title=\"Local Basemap\"\r\n",
    "    return render_template(\"index.html\", message=title, template_folder=\"templates\", static_folder=\"static\")\r\n",
    "\r\n",
    "@app.route(\"/shutdown\", methods=[\"GET\"])\r\n",
    "def shutdown():\r\n",
    "    shutdown_server()\r\n",
    "    return \"Server shutting down...\"\r\n",
    "\r\n",
    "if __name__ == \"__main__\":\r\n",
    "    from werkzeug.serving import run_simple\r\n",
    "    run_simple(\"localhost\", 9000, app)"
   ],
   "outputs": [
    {
     "output_type": "stream",
     "name": "stderr",
     "text": [
      " * Running on http://localhost:9000/ (Press CTRL+C to quit)\n",
      "127.0.0.1 - - [21/Sep/2021 14:27:50] \"GET / HTTP/1.1\" 200 -\n"
     ]
    }
   ],
   "metadata": {}
  }
 ],
 "metadata": {
  "language_info": {
   "name": "python",
   "version": "3.8.8",
   "mimetype": "text/x-python",
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "pygments_lexer": "ipython3",
   "nbconvert_exporter": "python",
   "file_extension": ".py"
  },
  "kernelspec": {
   "name": "python3",
   "display_name": "Python 3.8.8 64-bit"
  },
  "interpreter": {
   "hash": "98626cbbe5e851a1d0ee34e6b7efd7b6126696304d755598f28258550d4df674"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}