Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix/thumbnails-proxy #268

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions apptax/taxonomie/filemanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,11 +231,16 @@ def url_to_image(url):
"""
Récupération d'une image à partir d'une url
"""

r = requests.get(url, stream=True)

if (r.status_code >= 400):
raise Exception("Pb with request : status code {}".format(r.status_code))
try:
img = Image.open(io.BytesIO(r.content))
except IOError:
raise Exception("Media is not an image")

return img


Expand Down
7 changes: 7 additions & 0 deletions gunicorn_start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ echo "$FLASKDIR"

. "$FLASKDIR"/settings.ini

if [ ! -z "$proxy_http" ] || [ ! -z "$proxy_https" ]
then
echo "\$proxy_http is NOT empty"
export HTTP_PROXY="'$proxy_http'"
export HTTPS_PROXY="'$proxy_https'"
fi

# activate the virtualenv
cd $FLASKDIR/$venv_dir
source bin/activate
Expand Down
5 changes: 5 additions & 0 deletions settings.ini.sample
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,8 @@ insert_taxons_example=true
gun_num_workers=4
gun_host=0.0.0.0
gun_port=5000

# Proxy - si le serveur sur lequel se trouve Taxhub se trouve derrière un proxy
# laisser vide si vous n'avez pas de proxy
proxy_http=
proxy_https=