title: Show basic auth popup if user is not logged in
body: <p>I have several files that can be downloaded on my website. 
  The HTML content refers to this method:</p>
  
  <pre><code>from flask_httpauth import HTTPBasicAuth
  auth = HTTPBasicAuth()
  ...
  @app.route('/customer_section/download/&lt;product_id&gt;')
  @login_required
  def customer_download_file(product_id):
      # get the company the currently logged in user belongs to
      user_company = current_user.company
  
      # get the product entity
      product = Product.query.filter_by(id=product_id).first_or_404()
  
      # now get the company, the product belongs to
      product_company = product.project.owner
  
      if current_user.is_admin or (not current_user.is_admin and product_company.id == user_company.id):
  
          print("Splitting Path %s to folder and filename..." % product.path)
  
          # Split the path to folder and filename
          folder, filename = os.path.split(product.path)
  
          return send_from_directory(folder, filename, mimetype="application/octet-stream", as_attachment=True)
      else:
          # Unauthorized
          abort(401)
  </code></pre>
  
  <p>This works great when the user logs in via flask_login in my login view. 
  So the user logs in via my login view, then somehow navigates through my website, and the clicks on a download link to download a file. </p>
  
  <p>But what if a user tries to download a file directly? 
  I'd then like to show the user a popup so the user can enter his credentials and may download the file. </p>
  
  <p>Is this possible?</p>
  
  <p>Sorry, I guess my description was not clear enough: I‘m not trying to show a custom popup view of mine when a user calls my download method. I‘d like the default (browser specific) Basic Authentication popup to appear if a non logged in user tries to call that specific url. As if I had a restrictive .htaccess file that ensures that only authorized users continue. If the user reaches the same url via my webpage (after logging in, this method simply returns the file stream). </p>