Note that there are some explanatory texts on larger screens.

plurals
  1. POPython Cherrypy: 500 ValueError: Page handlers MUST return bytes
    primarykey
    data
    text
    <p>I'm getting the following error from my cherrypy script that is being generated by the submit module. </p> <p>ValueError: Page handlers MUST return bytes. Use tools.encode if you wish to return unicode</p> <p>I turned tool.encode on in my config but I'm still getting this error. I'm allowing users to upload content via the jQuery Form Plugin. Anythoughts as to why I'm getting this error?</p> <p>Here is my cherrypy file:</p> <pre><code>class Root(object): @cherrypy.expose def index(self) return open('/home/joestox/webapps/freelinreg_static/index.html') @cherrypy.expose def submit(self, myfile): cherrypy.session['myfile'] = myfile data_name = myfile.filename #Send back to JQuery with Ajax #Put in JSON form data_name= json.dumps(dict(title = data_name)) cherrypy.response.headers['Content-Type'] = 'application/json' return data_name cherrypy.config.update({ 'tools.staticdir.debug': True, 'log.screen': True, 'server.socket_host': '127.0.0.1', 'server.socket_port': *****, 'tools.sessions.on': True, 'tools.encode.on': True, 'tools.encode.encoding': 'utf-8', }) config = { } cherrypy.tree.mount(Root(), '/', config=config) cherrypy.engine.start() </code></pre> <p>HTML:</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;script type='text/javascript' src='freelinreg_static/google.js'&gt;&lt;/script&gt; &lt;script type='text/javascript' src='freelinreg_static/frontend.js'&gt;&lt;/script&gt; &lt;script type='text/javascript' src='freelinreg_static/malsup.js'&gt;&lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;form id="dataform" action="submit" method="post" enctype="multipart/form-data"&gt; &lt;input type="file" name="myfile" id="myFile"/&gt; &lt;input type="submit" id="data_submit" value="Continue"/&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>jQuery (frontend.js):</p> <pre><code>$(document).ready(function () { (function () { $('#dataform').ajaxForm({ url: "submit", success: function (data) { var $a_var = data['title']; $('body').append($a_var); } }); return false; })(); }); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload