title: How to define a base route in Flask API routing system
body: <p>In some frameworks like slim php framework you can define base route that is the same in all routes like <code>/api/v1</code>.</p>
  
  <p>So in slim we can group route to not put <code>/api/v1</code> in every route:</p>
  
  <pre><code>$app-&gt;group('/api/v1', function () use ($app) {
  
          // Get book with ID
          $app-&gt;get('/books/:id', function ($id) {
  
          });
  
          // Update book with ID
          $app-&gt;put('/books/:id', function ($id) {
  
          });
  
          // Delete book with ID
          $app-&gt;delete('/books/:id', function ($id) {
  
          });
  
  });
  </code></pre>
  
  <p>But in Flask I couldn't find an easy way to group routes. What if I have to write <code>/api/v1</code> in every resource I call? Is there a way to group them?</p>
  
  <p>In python I should use something like below:  </p>
  
  <pre><code>class TaskListAPI(Resource):
      def get(self):
          pass
  
      def post(self):
          pass
  
  class TaskAPI(Resource):
      def get(self, id):
          pass
  
      def put(self, id):
          pass
  
      def delete(self, id):
          pass
  
  api.add_resource(TaskListAPI, '/api/v1/tasks', endpoint = 'tasks')
  api.add_resource(TaskAPI, '/api/v1/tasks/&lt;int:id&gt;', endpoint = 'task')
  </code></pre>