WebFaction
Community site: login faq

I'm using cherrypy with the jquery form plugin to allow users to upload a file to my site. This works fine on my localhost:8080 but not when I upload the site to webfaction. I believe the problem is as simple as the jquery looking in the wrong spot for my cherrypy file so I'll list the differences I see between running on localhost and on webfaction.

When I upload a file running my site off of localhost, the jquery looks for my exposed cherrypy model at "localhost:8080/submit", where "submit" is the name of the module (see below).

Running my site on webfaction I get this error when I try to use the jquery to upload a file: [error] 26628#0: *2912993 open() "/home/mywebsite/webapps/htdocs/submit" failed (2: No such file or directory)

It looks like its looking in the wrong place. My site is organised as:

/webapps
    /freelinreg
        site.py (my cherrypy file)
    /freelinreg_static
        (my index.html, and all my .js, and .css files)
    /htdocs
        (some other index.html that I don't use)

Here is my cherrypy file:

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,
})

config = {
}

cherrypy.tree.mount(Root(), '/', config=config)
cherrypy.engine.start()

HTML:

<!DOCTYPE html>
    <html>
        <head> 
            <script type='text/javascript' src='freelinreg_static/google.js'></script>
            <script type='text/javascript' src='freelinreg_static/frontend.js'></script>
            <script type='text/javascript' src='freelinreg_static/malsup.js'></script>
        </head>
        <body>

        <form id="dataform" action="submit" method="post" enctype="multipart/form-data">
            <input type="file" name="myfile" id="myFile"/>
            <input type="submit" id="data_submit" value="Continue"/>
        </form>

        </body>
    </html>

jQuery (frontend.js):

$(document).ready(function () {
    (function () {
        $('#dataform').ajaxForm({
            url: "submit",
            success: function (data) {
                var $a_var = data['title'];
                $('body').append($a_var);
            }
        });
        return false;
    })();
});

asked 25 Nov '13, 04:17

joestox
31713
accept rate: 0%

edited 25 Nov '13, 08:49

Please open a support ticket so we can take a closer look. :)

(25 Nov '13, 14:06) likebike
Be the first one to answer this question!
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×337
×32
×9

question asked: 25 Nov '13, 04:17

question was seen: 2,723 times

last updated: 25 Nov '13, 14:06

                              
WEBFACTION
REACH US
SUPPORT
LEGAL
© COPYRIGHT 2003-2021 SWARMA LIMITED - WEBFACTION IS A SERVICE OF SWARMA LIMITED
REGISTERED IN ENGLAND AND WALES 5729350 - VAT REGISTRATION NUMBER 877397162
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM