title: Flask using id to personalise landing page
body: <p>I am working through the flask tutorial. I am trying to tinker with the tutorial code to better understand it. Below is the code for the homepage. It accesses all the posts people have written on the blog.</p>
  <pre><code>@bp.route('/')
  def index():
      db = get_db()
      posts = db.execute(
          'SELECT p.id, title, body, created, author_id, username'
          ' FROM post p JOIN user u ON p.author_id = u.id'
          ' ORDER BY created DESC'
      ).fetchall()
      return render_template('blog/index.html', posts=posts)
  </code></pre>
  <p>I was trying to adjust it so that it only shows posts which that user wrote. As a starting point, I tried to pass in id as an input variable to the index() function, much like the function get_post() does (see below)</p>
  <pre><code>@bp.route('/create', methods=('GET', 'POST'))
  @login_required
  
  ...
  
  def get_post(id, check_author=True):
      post = get_db().execute(
          'SELECT p.id, title, body, created, author_id, username'
          ' FROM post p JOIN user u ON p.author_id = u.id'
          ' WHERE p.id = ?',
          (id,)
      ).fetchone()
  
      if post is None:
          abort(404, &quot;Post id {0} doesn't exist.&quot;.format(id))
  
      if check_author and post['author_id'] != g.user['id']:
          abort(403)
  
      return post
  </code></pre>
  <p>However, this throws an error with id not recognised as an input variable. This happens when I add the @login_required, and when I tried changing the ip address to '/int:id//' which was used in another function which took in id as an input.</p>
  <p>thank you for your help:))</p>