Protected directories and Files - Flask Web Development with Python 31

preview_player
Показать описание
In this Flask web development tutorial, we're going to cover how to protect files in a protected directory that you want some people to be able to access, but not everyone.

To start, we need some sort of super secret file. I will just use a Python logo. Use whatever you like. Next, we need to add an instance path to our application. By default, the only place that Flask will look for files within your app will be the static directory. We could put the file in there, but the static directory is completely public, so that won't work, we need to create a new one.

Рекомендации по теме
Комментарии
Автор

If You want to remove directory listing in Apache, go to website config file and remove "Indexes" from Your <Directory> directive(s) or create .htaccess file on webroot drectory with: Options -Indexes

QWACHU
Автор

It is good to mention, that if You pass as_attachment=True to send_from_directory(), then you can force file download by client web browser.
There will be no need to put target="_blank" in anchor links :)

QWACHU
Автор

Hi Sentdex,
i am using webkitdirectory compnent at html form to upload files. could you please help to get the directory full path of selected file from the python

ravindranathreddy
Автор

my code doesnt show the picture what the hell do i

arshamshirkouhi
Автор

Hi Harrison,

Could you please do some tutorial on using python to handle PDF files such as generate PDF from HTML template then email them to use? Thanks a lot for all Flask tutorial. They're awesome.

tungfx
Автор

There is no way to protect static directory?

russomario