title: How can i write a switch statement in python using flask framework?
body: <p>Here is the code</p>
  
  <pre><code>switcher = {
      "1": func1(),
      "2": func2(),
      "3": func3(),
      "4": func4(),
      "5": func5(),
      "6": func6(),
      "9": func7(),
      "11": func8(),
      "12":func9(),
      "13": func10()
  }
  
  @app.route('/ussdcallback', methods=['GET', 'POST'])
  def switch(text = request.values.get("text", None)):
      session_id = request.values.get("sessionId", None)
      service_code = request.values.get("serviceCode", None)
      func = switcher.get(text, "none")
      return func()
  </code></pre>
  
  <p>This is the output i get</p>
  
  <pre><code>Traceback (most recent call last):
  2020-05-19T05:44:17.416279+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/arbiter.py", line 583, in spawn_worker
  2020-05-19T05:44:17.416279+00:00 app[web.1]:     worker.init_process()
  2020-05-19T05:44:17.416280+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/workers/base.py", line 119, in init_process
  2020-05-19T05:44:17.416280+00:00 app[web.1]:     self.load_wsgi()
  2020-05-19T05:44:17.416280+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/workers/base.py", line 144, in load_wsgi
  2020-05-19T05:44:17.416280+00:00 app[web.1]:     self.wsgi = self.app.wsgi()
  2020-05-19T05:44:17.416281+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/base.py", line 67, in wsgi
  2020-05-19T05:44:17.416281+00:00 app[web.1]:     self.callable = self.load()
  2020-05-19T05:44:17.416281+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 49, in load
  2020-05-19T05:44:17.416281+00:00 app[web.1]:     return self.load_wsgiapp()
  2020-05-19T05:44:17.416282+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 39, in load_wsgiapp
  2020-05-19T05:44:17.416282+00:00 app[web.1]:     return util.import_app(self.app_uri)
  2020-05-19T05:44:17.416282+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/util.py", line 358, in import_app
  2020-05-19T05:44:17.416282+00:00 app[web.1]:     mod = importlib.import_module(module)
  2020-05-19T05:44:17.416283+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/importlib/__init__.py", line 126, in import_module
  2020-05-19T05:44:17.416284+00:00 app[web.1]:     return _bootstrap._gcd_import(name[level:], package, level)
  2020-05-19T05:44:17.416285+00:00 app[web.1]:   File "&lt;frozen importlib._bootstrap&gt;", line 994, in _gcd_import
  2020-05-19T05:44:17.416285+00:00 app[web.1]:   File "&lt;frozen importlib._bootstrap&gt;", line 971, in _find_and_load
  2020-05-19T05:44:17.416285+00:00 app[web.1]:   File "&lt;frozen importlib._bootstrap&gt;", line 955, in _find_and_load_unlocked
  2020-05-19T05:44:17.416285+00:00 app[web.1]:   File "&lt;frozen importlib._bootstrap&gt;", line 665, in _load_unlocked
  2020-05-19T05:44:17.416286+00:00 app[web.1]:   File "&lt;frozen importlib._bootstrap_external&gt;", line 678, in exec_module
  2020-05-19T05:44:17.416286+00:00 app[web.1]:   File "&lt;frozen importlib._bootstrap&gt;", line 219, in _call_with_frames_removed
  2020-05-19T05:44:17.416286+00:00 app[web.1]:   File "/app/run.py", line 1, in &lt;module&gt;
  2020-05-19T05:44:17.416286+00:00 app[web.1]:     from app import app
  2020-05-19T05:44:17.416286+00:00 app[web.1]:   File "/app/app/__init__.py", line 359, in &lt;module&gt;
  2020-05-19T05:44:17.416287+00:00 app[web.1]:     from app import routes, usrmgt, safeDeposit
  2020-05-19T05:44:17.416287+00:00 app[web.1]:   File "/app/app/routes.py", line 22, in &lt;module&gt;
  2020-05-19T05:44:17.416287+00:00 app[web.1]:     "1": radar(),
  2020-05-19T05:44:17.416287+00:00 app[web.1]:   File "/app/app/radar.py", line 161, in radar
  2020-05-19T05:44:17.416287+00:00 app[web.1]:     resp = make_response(response, 200)
  2020-05-19T05:44:17.416288+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/flask/helpers.py", line 223, in make_response
  2020-05-19T05:44:17.416288+00:00 app[web.1]:     return current_app.make_response(args)
  2020-05-19T05:44:17.416288+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/werkzeug/local.py", line 347, in __getattr__
  2020-05-19T05:44:17.416288+00:00 app[web.1]:     return getattr(self._get_current_object(), name)
  2020-05-19T05:44:17.416288+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/werkzeug/local.py", line 306, in _get_current_object
  2020-05-19T05:44:17.416289+00:00 app[web.1]:     return self.__local()
  2020-05-19T05:44:17.416289+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/flask/globals.py", line 52, in _find_app
  2020-05-19T05:44:17.416311+00:00 app[web.1]:     raise RuntimeError(_app_ctx_err_msg)
  2020-05-19T05:44:17.416312+00:00 app[web.1]: RuntimeError: Working outside of application context.
  2020-05-19T05:44:17.416312+00:00 app[web.1]: 
  2020-05-19T05:44:17.416313+00:00 app[web.1]: This typically means that you attempted to use functionality that needed
  2020-05-19T05:44:17.416313+00:00 app[web.1]: to interface with the current application object in some way. To solve
  2020-05-19T05:44:17.416313+00:00 app[web.1]: this, set up an application context with app.app_context().  See the
  2020-05-19T05:44:17.416319+00:00 app[web.1]: documentation for more information.
  2020-05-19T05:44:17.416716+00:00 app[web.1]: [2020-05-19 05:44:17 +0000] [11] [INFO] Worker exiting (pid: 11)
  2020-05-19T05:44:18.050667+00:00 app[web.1]: [2020-05-19 05:44:18 +0000] [4] [INFO] Shutting down: Master
  2020-05-19T05:44:18.050834+00:00 app[web.1]: [2020-05-19 05:44:18 +0000] [4] [INFO] Reason: Worker failed to boot.
  2020-05-19T05:44:18.145123+00:00 heroku[web.1]: Process exited with status 3
  2020-05-19T05:44:18.190532+00:00 heroku[web.1]: State changed from up to crashed
  </code></pre>