added a public static folder path for flask to not break the image links
This commit is contained in:
parent
678e40334e
commit
f732927679
@ -5,6 +5,7 @@ import json
|
||||
import jinja2
|
||||
|
||||
STATIC_FOLDER_PATH = '.' # without trailing slash
|
||||
PUBLIC_STATIC_FOLDER_PATH = '.' # without trailing slash
|
||||
WRAPPING_TEMPLATES_DIR = './templates'
|
||||
|
||||
# This uses a low quality copy of all the images
|
||||
@ -81,7 +82,7 @@ def download_media(html, images, wiki):
|
||||
time.sleep(3) # do not overload the server
|
||||
|
||||
# replace src link
|
||||
image_path = f'{ STATIC_FOLDER_PATH }/images/{ filename }' # here the images need to link to the / of the domain, for flask :/// confusing! this breaks the whole idea to still be able to make a local copy of the file
|
||||
image_path = f'{ PUBLIC_STATIC_FOLDER_PATH }/images/{ filename }' # here the images need to link to the / of the domain, for flask :/// confusing! this breaks the whole idea to still be able to make a local copy of the file
|
||||
matches = re.findall(rf'src="/book/images/.*?px-{ filename }"', html) # for debugging
|
||||
if matches:
|
||||
html = re.sub(rf'src="/book/images/.*?px-{ filename }"', f'src="{ image_path }"', html)
|
||||
|
@ -6,6 +6,7 @@ import jinja2
|
||||
|
||||
|
||||
STATIC_FOLDER_PATH = './static' # without trailing slash
|
||||
PUBLIC_STATIC_FOLDER_PATH = '/static' # without trailing slash
|
||||
WRAPPING_TEMPLATES_DIR = './wrapping-templates'
|
||||
|
||||
# This uses a low quality copy of all the images
|
||||
@ -82,7 +83,7 @@ def download_media(html, images, wiki):
|
||||
time.sleep(3) # do not overload the server
|
||||
|
||||
# replace src link
|
||||
image_path = f'{ STATIC_FOLDER_PATH }/images/{ filename }' # here the images need to link to the / of the domain, for flask :/// confusing! this breaks the whole idea to still be able to make a local copy of the file
|
||||
image_path = f'{ PUBLIC_STATIC_FOLDER_PATH }/images/{ filename }' # here the images need to link to the / of the domain, for flask :/// confusing! this breaks the whole idea to still be able to make a local copy of the file
|
||||
matches = re.findall(rf'src="/book/images/.*?px-{ filename }"', html) # for debugging
|
||||
if matches:
|
||||
html = re.sub(rf'src="/book/images/.*?px-{ filename }"', f'src="{ image_path }"', html)
|
||||
|
Loading…
Reference in New Issue
Block a user