I need to serve static files, like images and videos through URLs securely. That is, I need to password protect them. Is there any way I can prompt a password input when the user visits the URL or accept a password in any other way so that before loading the image, the browser asks for a password and gets a password from the session or something?
Basically, I am looking for a Python version to what is being done in the accepted answer here.
Using PHP/Apache to restrict access to static files (html, css, img, etc)
I would consider a generic solution that doesn't belong to a specific programming language, in case I thought your needs are a basic need that can be accessed by only a webserver I'll use
nginxto illustrate my answer tho.Firstly, using
apache2-utilsutility package to create users and their passwordthen use
auth_basicandauth_basic_user_filedirectives to achieve username:password authenticationIf you want to learn more about how to limit resource access with
nginx, you can find additional information on the topic.