2

and python/cherrypy server

@cherrypy.tools.json_out()
@cherrypy.tools.json_in()
def get_data(self):
    cherrypy.response.headers['Content-Type'] = 'application/json'
    datas = {"ABCDEF"}
    return datas

but I get a Internal Server Error (500), where is my mistake? I get work to post data to server, but with getting data is my problem..

0

2 Answers 2

2

One problem is in your fifth line of your second code block. Change

datas = {"ABCDEF"}

to something like

datas = { "somedata" : "ABCDEF"}

And if this is all of your cherrypy server code, you're not exposing your route. Then you have to add the

@cherrypy.expose

annotation. You can consult the docs for this as well.

Sign up to request clarification or add additional context in comments.

1 Comment

thank you very much, whatever i forgot the line:@cherrypy.expose
0

Your datas variable is a Python set, and those are not directly serialisable to JSON. Perhaps you meant to create a dictionary or list?

1 Comment

at the moment this was an example, because the variable should contains a value from sql query,that is executed before.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.