N
N
nano_e_t_42016-06-30 02:54:36
Flask
nano_e_t_4, 2016-06-30 02:54:36

How to specify "external directory" as file storage?

Hello everyone
Plz tell me How to specify the "external directory" as the file storage?
Clarification\example:
there is img:

<img src="/static/filestorage/dart.jpg" alt="Письма мастера дзен">

flask returns the 200th status, everything is OK, but the file is located in the directory (from the fs root):
/home/user/project_name/app/static/filestorage/dart.jpg

and I, for example, need to specify the directory for storage:
/var /filestorage/dart.jpg (starting from fs root)

plz tell me how to do it. but rather poke into the documentation, tk. I have not found such information yet
ps It is
worth adding that the file name in src will be set by a macro, so using the "frontend" server (Jinx Apache, etc.) does not make sense, because the application logic does not allow
Thank you

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
intelligence, 2016-06-30
@intelligence

1. ln -s /var/filestorage /home/user/project_name/app/static/filestorage
2. specify the required location in nginx (or other web server):

location /filestorage {
root /var;
}

V
VanSanblch, 2016-06-30
@VanSanblch

Maybe this can help you:

flask.pocoo.org/docs/0.11/api/#flask.send_from_dir...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question