Re: Display the Web2py image

62 views
Skip to first unread message
Message has been deleted

Dave S

unread,
Jun 27, 2019, 10:49:18 PM6/27/19
to web2py-users


On Thursday, June 27, 2019 at 5:07:14 PM UTC-7, Quang Lam wrote:
i have a trouble with displaying image stored in my local folder

</div>
{{for r in plot_list:}}
{{ if r.endswith('.html'):}}
<div class="plot_path" id ={{=plot_list.index(r)}}  style = 'width:100%; height:500px; display:none' >
{{=IFRAME(_src=r, _style = 'width:100%; height:100%; border: 0') }}
</div>
{{else:}}
<div class="plot_path" id ={{=plot_list.index(r)}}  style = 'width:100%; height:500px; display:none' >
{{=IMG(_src=r, _style = 'width:100%; height:100%; border: 0') }}
</div>
{{pass}}
{{pass}}
</div>

i can display the HTML files in the same folder but not the png file and jpg file, please help 
Thanks

What folder are the files in?   If you use the browser developer tools, what do you see being used for the URL that is being requested?

/dps
 
Message has been deleted

Dave S

unread,
Jun 28, 2019, 3:56:24 PM6/28/19
to web...@googlegroups.com


On Friday, June 28, 2019 at 7:20:21 AM UTC-7, Quang Lam wrote:
this the URL https://xxx.xx.xxx.xx:8898/ftds/view/view_custom_search and the image will be expected to display on the same page

this the file location in controller

    file_location = os.path.join(request.folder, 'views','Plot')
    plot_list = os.listdir(file_location)

this is in the view:
{{for r in plot_list:}}
{{ if r.endswith('.html'):}}
<div class="plot_path" id ={{=plot_list.index(r)}}  style = 'width:100%; height:500px; display:none' >
{{=IFRAME(_src=r, _style = 'width:100%; height:100%; border: 0') }}
</div>
{{else:}}
<div class="plot_path" id ={{=plot_list.index(r)}}  style = 'width:100%; height:500px; display:none' >
{{=IMG(_src=r, _style = 'width:100%; height:100%; border: 0') }}
</div>
{{pass}}
{{pass}}
</div>

the HTML file is displayed on the same page correctly but not the images (it's blank) even though they're both in the same folder.
Please help, Thanks


I'm specifically interested in what the browser thinks the URLs are; you seem to be using relative URLs in your code, and perhaps the IFRAME() helper and the IMG() helper compute that differently.  Although I would expect you to need 'Plot' in the URLs for both.
Are you using routes.py at all?

PS:  A quick look at gluon/html.py suggests they both just set a tag and call DIV().

/dps

Message has been deleted

Dave S

unread,
Jun 28, 2019, 5:43:01 PM6/28/19
to web...@googlegroups.com


On Friday, June 28, 2019 at 1:10:18 PM UTC-7, Quang Lam wrote:
you mean src = _Plot/r ?

well, something like _src = "Plot/" + r

(URLs always use '/', so you don't need to do an "os.join()")


And I'm still interested in the browser's reading of the URL.  Perhaps you can use the devtool's "Inspect Element"  to grab the <A> tags and post them here.

/dps

Reply all
Reply to author
Forward
0 new messages