last day (22 days later) » 

8:06 AM
1
A: How to convert multiple image in base64 and return in json format and display in html?

loginmind but the result only display certain result only Put return inside for loop will exit the for loop immediately after first iteration. You need to make a list, then append new data on each iteration.

 
Hi @loginmind , I try print final_data.files[0].label but it's display result something like this 'str' object has no attribute 'files'. Currently, i still fail to display my result in html
 
Hi @adam919191, I found that in @aminrd solution, json.dump would return json format means it's string type. That is why you got error 'str' object has no attribute 'files'.
 
Thank you for your response. I still working on this.. but still fail to get the result
 
What error you got now?
 
I still don't able to print the result in html..it's just display the header..but don't display the data
 
8:06 AM
For working with problem like this, I suggest you working with mock data. You need to divide problem into two task: render html, and build data. Test each task with mock data first then combine them.
 
hye @loginmind
 
hi
 
thank you for your help
 
what's your problem now
 
right now i am not able to display my json data into html
 
8:08 AM
can you mock json data first the check if it work?
 
yup
json data return well ly
 
final_data = json.dumps({'files':flist}, sort_keys=True, indent=4, separators=(',', ': '))
 
let's me show you
yup
 
this line will not work because it's wrong
 
really
so what should i change
 
8:11 AM
simply use final_data = {'files':flist}
html render accept dict type, not json
 
oke let me try
mean render only accept dictionary and not json?
 
json is just string in Python
 
means render templete dont accept the json format?
 
:48567752
 
only accept the dictionary right?
 
8:15 AM
no it accepts
because json is just string, so when you display it in html
it just means you display a text
have you tested my suggestion?
 
yup i already test
it's works
my last question
 
cheers
 
i still confused with the dumps json
 
yes, I need to comeback to work soon
 
as per my understanding dumps is convert to string format
but why do we need to put dictionary in render templete
 
8:18 AM
Maybe I will answer you when I finish work, just post your question here
 
why not we just use string
oke sorry for disturbing you..thank you for your help btw
 
By the way, please check answer on SO as accepted if you found it's helpful
 
do i need to check aminrd one or yours
:D
and my another question i plan to update my web update when my json data increasing? how can i solve this? hope you can share the idea then i will google on my own
 
 
5 hours later…
1:11 PM
Hi, i'm free now so I will answer your question
@adam919191 No it's not required, you can simply put a list in render template
About update web content update, I'm not sure if I understand your question, but simply exposed your API, it will return new data when data is updated
 

  last day (22 days later) »