title: Running fastapi within class
body: <pre class="lang-py prettyprint-override"><code>import uvicorn
  from fastapi import FastAPI
  
  # 2. Create the app object
  app = FastAPI()
  
  # 3. Index route, opens automatically on http://127.0.0.1:8000
  class RunModel():
      @app.get('/')
      def index(self):
          return {'message': 'Hello'}
  
      @app.get('/predict')
      def get_res(self, feat1: float, feat2:float):
          res = feat1 + feat2
          return {'result': f'{res:.4f}'}
  
  run_model = RunModel()
  # 5. Run the API with uvicorn
  #    Will run on http://127.0.0.1:8000
  if __name__ == '__main__':
      uvicorn.run(app, host='127.0.0.1', port=8000)
  </code></pre>
  <p>When I run this first of all I get the error (in terminal and not browser) <code>422 Unprocessable Entity</code>. Next thing is when I go to the http://localhost:8000/docs it seems like it is expecting me to enter 3 values for <code>/predict</code> route, the two features as expected <strong>and self</strong>. So the question is how can I use this class structure and still use fastapi (i.e. ignore <code>self</code>).</p>