title: Executing different functions on the running server in python
body: <p>I am trying to parse a HTML document in it by beautifulSoup.</p>
  
  <p>I have 2 separate sections in the document. </p>
  
  <p>Below is my code.</p>
  
  <pre><code>import os
  import json
  import requests
  import cherrypy
  import ConfigParser
  from bs4 import BeautifulSoup
  
  class Server():
  
      @cherrypy.expose
      def index(self):
  
          return "Seems Like You're Lost :D"
  
  
      @cherrypy.expose
      def recharge_list(self,carrier, state):
          details_array=[]
          small_details_array=[]
          price_cell_array=[]
          lst = []
          url = "link/{}/{}".format(carrier,state)
          try:
              if self.t_arr.get(url) is not None:
                  return json.dumps({'data': self.t_arr[url]})
          except AttributeError:
              self.t_arr = {}
          r  = requests.get(url)
          data = r.text
          soup = BeautifulSoup(data,"html.parser")
          table = soup.find('table',{'class':'table'})
          s=""
          detailtext = table.findAll('div',{'class':'detailtext'})
  
  
          for det in detailtext:
              details_array.append(det.text)
  
          smalldetails = table.findAll('div',{'style':'padding-top:5px'})
  
          for smallDet in smalldetails:
              small_details_array.append(smallDet.text);
  
  
          price_cells = table.findAll('td', {'class': 'pricecell'})
          for price_cell in price_cells:
              price_cell_array.append(price_cell.text)
  
          for i in range(len(details_array)):
              d_arr = {}
              d_arr['detail']=details_array[i]
              temp = small_details_array[i].split('\n')
              d_arr['talktime'] = temp[1] 
              d_arr['keyword']=temp[3]
              tempnew = price_cell_array[i].split('\n')
              d_arr['price'] = tempnew[1]
              d_arr['validity'] = tempnew[3]
              # global list
              lst.append(d_arr)
          self.t_arr[url] = lst
          return json.dumps({'data': self.t_arr[url]})
  
      @cherrypy.expose
      def sms_list(self,carrier, state):
          details_array=[]
          price_cell_array=[]
          lst = []
          url = "link/{}/{}".format(carrier,state)
          try:
              if self.t_arr.get(url) is not None:
                  return json.dumps({'data': self.t_arr[url]})
          except AttributeError:
              self.t_arr = {}
          r  = requests.get(url)
          data = r.text
          soup = BeautifulSoup(data,"html.parser")
          table = soup.find('div',{'id':'SMS'})
          table2 = table.find('table',{'class':'table'})
          print(table2)
          s=""
          detailtext = table2.findAll('div',{'class':'detailtext'})
  
  
          for det in detailtext:
              details_array.append(det.text)
  
          smalldetails = table2.findAll('div',{'style':'padding-top:5px'})
  
  
          price_cells = table.findAll('td', {'class': 'pricecell'})
          for price_cell in price_cells:
              price_cell_array.append(price_cell.text)
  
          for i in range(len(details_array)):
              d_arr = {}
              d_arr['detail']=details_array[i]
              tempnew = price_cell_array[i].split('\n')
              d_arr['price'] = tempnew[1]
              d_arr['validity'] = tempnew[3]
              # global list
              lst.append(d_arr)
          self.t_arr[url] = lst
          return json.dumps({'data': self.t_arr[url]})
  
  if __name__ == '__main__':
      ''' Setting up the Server with Specified Configuration'''
  
      cherrypy.config.update({'server.socket_host': '0.0.0.0',})
      cherrypy.config.update({'server.socket_port': int(os.environ.get('PORT', '5000')),})
  
  cherrypy.quickstart(Server())
  </code></pre>
  
  <p>The problem is that, whenever I start my server the first default function or first called function executes, but if I try to call another function, it shows old values of previously called function.</p>
  
  <p>For ex:- the code has 2 function <code>recharge_list</code> &amp; <code>sms_list</code> . Now if I start the server by <code>recharge_list</code> then I have to restart the server to call the <code>sms_list</code> the already running server does not serve the newly called function.</p>
  
  <p>What should be added in the script to make it run ?</p>
  
  <p>I accept that this is a silly question, but I do not know how to get this fixed.</p>