Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6101947
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T13:33:28+00:00 2026-05-23T13:33:28+00:00

I’m currently working on a project where we previously used Django. However this proved

  • 0

I’m currently working on a project where we previously used Django. However this proved a bit to heavyweight for our needs so we are shifting the project over to use cherrypy as we only really need to handle requests.

my problem is this. I have a form on the html page (index.html) when the user clicks submit the following jQuery function gets executed.

$(document).ready(function() {
    $("#loginform").submit(function() {
        var request_data = {username:$("#username").val(),password:"test"};
        $.post('/request',request_data, function(data) {
                                        $("#error").html(data['response']);
        });
        return false;
    });
});

This works fine.
The following Cherrypy method should pick up the request data but it doesn’t seem to be executed. Here is the Cherrypy method for the request.

@cherrypy.expose
def request(self, request_data):
    print "Debug"
    cherrypy.response.headers['Content-Type'] = 'application/json'
    return simplejson.dumps(dict(response ="Invalid username and/or password"))

This is only a test method and I would expect to see ‘Debug’ come up in the terminal window and the error message displayed on the web page after the submit button is clicked

In terminal I get this message after the request is made:

"POST /request HTTP/1.1" 404 1254 "http://127.0.0.1:8080/" "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_7; en-us) AppleWebKit/533.21.1 (KHTML, like Gecko) Version/5.0.5 Safari/533.21.1"

This would indicate that it can’t find the request method. All I can think is it is something to do with the parameter.

As I am new to cherrypy I expect it is something simple that I am missing any pointers would be great.

PS: The following works but I need to be able to pass multiple data to cherrypy.
(The cherrypy parameter is changed to username to allow this to work)

$(document).ready(function() {
    $("#loginform").submit(function() {
        $.post('/request',{username:$("#username").val()}, function(data) {
                                        $("#error").html(data['response']);
        });
        return false;
    });
});

Thanks in advance for any help or guidance in this issue.

Here is my full cherrypy file.

import cherrypy
import webbrowser
import os
import simplejson
import sys
from backendSystem.database.authentication import SiteAuth

MEDIA_DIR = os.path.join(os.path.abspath("."), u"media")

class LoginPage(object):
@cherrypy.expose
def index(self):
    return open(os.path.join(MEDIA_DIR, u'index.html'))

@cherrypy.expose
def request(self, request_data):
    print "Debug"
    cherrypy.response.headers['Content-Type'] = 'application/json'
    return simplejson.dumps(dict(response ="Invalid username and/or password"))


config = {'/media': {'tools.staticdir.on': True, 'tools.staticdir.dir': MEDIA_DIR, }}

root = LoginPage()

# DEVELOPMENT ONLY: Forces the browser to startup, easier for development
def open_page():
webbrowser.open("http://127.0.0.1:8080/")
cherrypy.engine.subscribe('start', open_page)

cherrypy.tree.mount(root, '/', config = config)
cherrypy.engine.start()
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T13:33:29+00:00Added an answer on May 23, 2026 at 1:33 pm

    I have discovered the solution to this. JQuery:

    $(document).ready(function() {
        $("#loginform").submit(function() {
            $.post('/request',{username:$("#username").val(),password:"test"}, 
                   function(data) {
                       $("#error").html(data['response']);
            });
            return false;
        });
    });
    

    Then in the cherrypy method I do this:

    def request(self, **data):
        # Then to access the data do the following
        print data['<keyValue'] # In this example I would type print data['username']
    

    Simple really, a case of not being able to see the wood for the trees. Hope this helps someone else.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I used javascript for loading a picture on my website depending on which small
this is what i have right now Drawing an RSS feed into the php,
I want use html5's new tag to play a wav file (currently only supported
I am currently running into a problem where an element is coming back from
We're building an app, our first using Rails 3, and we're having to build
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.