-
Notifications
You must be signed in to change notification settings - Fork 43
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
URL normalization on Windows #25
Comments
You missed the URL scheme, probably http or https.
|
@iurisilvio is correct, but it still shouldn't be raising that particular error. =P |
I used the photo utilized in the Flask-Images demo: And the same error is still produced: ValueError Traceback (most recent call last) Any ideas? |
Would you mind sharing the configuration settings you used for the demo? (IMAGES_URL, IMAGES_NAME, IMAGES_PATH, etc.) Cloning your app I still get the same error. Is there a possibility that my OS (Windows) is the culprit? |
Yes! Windows is the problem! From Python docs (https://docs.python.org/2/library/os.path.html#os.path.normpath):
https://github.com/mikeboers/Flask-Images/blob/master/flask_images/core.py#L142 |
So that appears to be an oversight on my part. I guess I get to re-implement that logic, OR just use the There is no additional configuration for the deployed demo. |
Thanks for the lead. Exactly how would os.parth.normpath be implemented? In the configuration settings like this...? IMAGES_PATH = os.path.normcase('/static') |
Check out the "windows" branch I just pushed; I tried fixing the one spot that I think is causing you problems. There may be more (I'm very much not a Windows users). |
Thanks for your assistance. I made the appropriate updates, but to no avail. Just for reference anytime I put the direct local path into the image tag there isn't a problem. But when I use a variable for the image src like {{ pic.picpath }} the image doesn't display. The URL for the image when the page loads is: http://localhost:5000/imgsizer/%7B%7Bpic.picpath%7D%7D?w=50&s=zLAooBQ9_nkRsrEKC7Q3WeXhJBc It seems as though the variable isn't converting properly. |
We don't parse strings as templates, so try passing the variable directly:
Cheers, Mike |
Awesome! I changed the syntax and now images stored locally are working. This is my content for the working tag. src={{ resized_img_src(pic.picpath, width=50) }} I updated the "posixpath" in core.py, but the external files are still having problems. I have a list of full path image links in a database I'm trying to display ie. 'http://www.example.com/pictures/pic.jpg' and that's when the ValueError is thrown or the image simply doesn't display. I'm assuming this has to do with the IMAGE_PATH? Do I need to specify As for "url_for" versus "resized_img_src" does it matter when linking to a file like the path mentioned above? |
Hooray!
Is it the same problem as before? If not, can we get a backtrace? Have you tried the "windows" branch?
No.
No.
No. They are functionally the same. The Thanks for sticking this out; I'd love to know that this works on Windows. Cheers, Mike |
@cassac, did this ever work out for you? |
@mikeboers, I had the same issue yesterday. The following changes were needed to get Flask-Images working for me on Windows: tomcart90@5086388 |
Running my server from localhost and trying to link to an external file produces a ValueError. Is this type of usage allowed?
src="{{resized_img_src('www.example.com/pics/mypicture.jpg'
it throws an error:
raise ValueError('path is not normalized')
The text was updated successfully, but these errors were encountered: