{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import requests\n",
    "import json"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "r = requests.get('http://127.0.0.1:5000/rasa')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<Response [200]>\n"
     ]
    }
   ],
   "source": [
    "print(r)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [],
   "source": [
    "data = json.loads(r.content)\n",
    "# data = json.loads(r.content.encode('utf-8'))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "salam\n"
     ]
    }
   ],
   "source": [
    "print(data)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "str"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "type(data)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<Response [404]>\n"
     ]
    }
   ],
   "source": [
    "r = requests.get('http://127.0.0.1:5000/rasa')\n",
    "print(r)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<Response [200]>\n",
      "{'data': 'salam'}\n",
      "<class 'dict'>\n",
      "salam\n"
     ]
    }
   ],
   "source": [
    "r = requests.get('http://127.0.0.1:5000/')\n",
    "print(r)\n",
    "data = json.loads(r.content)\n",
    "print(data)\n",
    "print(type(data))\n",
    "print(data['data'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<Response [200]>\n",
      "{'first': None, 'last': None}\n",
      "<class 'dict'>\n",
      "None\n"
     ]
    }
   ],
   "source": [
    "r = requests.get('http://127.0.0.1:5000/')\n",
    "print(r)\n",
    "data = json.loads(r.content)\n",
    "print(data)\n",
    "print(type(data))\n",
    "print(data['first'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<Response [200]>\n",
      "{'first': 'salam', 'last': None}\n",
      "<class 'dict'>\n",
      "salam\n"
     ]
    }
   ],
   "source": [
    "r = requests.get('http://127.0.0.1:5000/?fname=salam')\n",
    "print(r)\n",
    "data = json.loads(r.content)\n",
    "print(data)\n",
    "print(type(data))\n",
    "print(data['first'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<Response [200]>\n",
      "{'first': 'farid', 'last': 'hashemi'}\n",
      "<class 'dict'>\n",
      "farid\n"
     ]
    }
   ],
   "source": [
    "r = requests.get('http://127.0.0.1:5000/?fname=farid&lname=hashemi')\n",
    "print(r)\n",
    "data = json.loads(r.content)\n",
    "print(data)\n",
    "print(type(data))\n",
    "print(data['first'])"
   ]
  },
  {
   "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.0
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}