Forums

python flask with html

hello everyone i got new problem when i trying show photo in website using python flask it not show i don't know why my folder /home/lornsela/testdata/web/templates/ff/month.png i was test again and again but no work

test1) <img src="/home/lornsela/testdata/minitelegramapp/templates/ff/month.png" alt="Mini Logo" class="mini-logo">

test2) <img src="templates/ff/month.png" alt="Mini Logo" class="mini-logo">

i don't know why no working but if <img src="url_photo"> is working fine . pls help me

If you want files that are stored in your account to be publicly accessible on your website, then you'll need to set up a static file mapping. I'd suggest putting them in a different directory to your templates, however, as templates are meant to be private. A normal setup (based on the path you provided above) would be to have all static files in a directory like /home/lornsela/testdata/minitelegramapp/static, and then to share that as /static/ in the static files table. Then you can be sure that only files under that directory would be public.

so i must make new folder name static and add photo to folder static?

Yes, that's what I'd recommend.

no work sir i make folder static and add photo to folder .

when i trying show is no work i was test: note i was change name month.png to ffvipmonth.png 1): /ffvipmonth.png 2): /static/ffvipmonth.png 3): /static/ffvipmonth.png 4): /home/lornsela/testdata/minitelegramapp/templates/static/ffvipmonth.png

i don't why still no work !!

Check out this tutorial = https://www.geeksforgeeks.org/how-to-serve-static-files-in-flask/

still no work sir , when i was test other platform is working but in pythonanywhere no work

Are you using the static file mapping built into PythonAnywhere or the static file hosting in flask?