Forums

Pictures are not shown

My site has some matplotlib pictures. Sometimes they appear but sometimes they are not shown. why?

How are you serving them up?

The *.png pictures are in \home\myusername and the html code is something like <img width = "800px" height = "600px" src = 'http://www.pythonanywhere.com/user/myusername/files/home/myusername/picture.png"/>. Is it ok?

If you use Django you should probably make use of the static files feature, you can find it explained here.

I use flask and the files are created on the fly by Python.

I think there are some problems with server. I did not change anything and sometimes I received this message:

Internal Server Error

The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application.

Do the reason for the instability may be my free account?. Only two people know about this site

What does it say in your error log?

No messages in error log about this. But whenever I copy and paste the url of the picture, http://www.pythonanywhere.com/user/myusername/files/home/myusername/picture.png login and password are required. Can not I put my files in \home\myusername?

That is a link to your picture through our file interface. Since those URLs permit editing and deleting and so on, they are password-protected.

To get unauthenticated web access to static files, you need a web app with static files mappings. See the Help pages for various examples.

Glenn, the files are not static. They are generated by python code. Do you have any instructions for this type of file?

They are files on a disk, so, in this context, they are static and you should deal with them as static files.

Thanks a lot, Glenn. Everything is working fine!

lass="container-fluid m-3"> <div class="row"> <div class="col-lg-7 px-0"> <div class="owl-carousel main-carousel position-relative"> {% for post in posts %} {% if forloop.counter < 5 %} <div class="position-relative overflow-hidden" style="height: 500px;"> <img class="img-fluid h-100" src="{{post.image.url}}" alt="{{post.image.url}}" style="object-fit: cover;"> <div class="overlay"> <div class="mb-2"> <a class="badge badge-primary text-uppercase font-weight-semi-bold p-2 mr-2" href="">{{post.get_post_category_display}}</a> <a class="text-white" href="">{{post.date_posted|date:"M d, Y" }}</a> </div> <a class="h2 m-0 text-white text-uppercase font-weight-bold" href="">{{post.title|truncatewords:10}}</a> </div> </div> {% endif %} {% endfor %} </div> </div>

Above is the code in template file to get the url for the image

and here is my settings /static/ /home/glion/virgo-new/static

but the images are not showing on the page. i don't know to solve the problem

and here is the error

2022-01-09 19:26:44,612: Not Found: /media/static/images/nasa_JJt25ze.jpg 2022-01-09 19:26:44,621: Not Found: /media/static/images/nasa.jpg

Please I need help on how to do it

This is the path that is being printed out

/media/static/images/img.png

What do you map /media/ to?

This please => /home/glion/virgo-new/media/static/images

Then the file that you're trying to access should be on your disk at /home/glion/virgo-new/media/static/images/static/images/img.png

Thanks Glenn.

i have migrated from sqlite to mysql but i can't run migrations and then migrate because of this error.

RuntimeWarning: Got an error check ing a consistent migration history performed for database connection 'default': (1045, "Access denied for user 'glion'@'10.0.0.187' (using password: NO)") warnings.warn( No changes detected

I don't how to work my way out this. Please help?

Looks like there is something wrong in your database configuration. Maybe contact us on support@pythonanywhere.com if you do not want to discuss detail on open forums.

ok

I have deployed the Django app successfully and it has been working properly, but now it's no longer show images on my site. The images are in a static folder and some in sqlite3 db. All are not longer showing and I did not change anything

Have you checked for matching errors in your web app's error log? The logs are accessible via the Web page.