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 7857359
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T21:01:31+00:00 2026-06-02T21:01:31+00:00

I’m new to Python and I’m having a problem viewing error messages: I have

  • 0

I’m new to Python and I’m having a problem viewing error messages: I have a javascript function making a call like:

$.getJSON('test.py', {data: 'somedata'}, function(return){alert(return.echo)})

And a test.py file successfully echoing that message:

def application(environ, start_response):
  import json
  status = '200 OK'
  response_headers = [('Content-type', 'application/json')]
  start_response(status, response_headers)
  data = environ['QUERY_STRING'].split('=')[1])   
  return json.dumps({'echo': data}, separators=(',',':'))

NB: I just retyped that script from memory so if you notice a syntactical error it’s me keying it wrong, the base script is working fine.

If i run the page with the call, I get my alert, and then if I visit the Network tab in Chrome, I see

Request URL:http://localhost/test.py?data=somedata
Request Method:GET
Status Code:200 OK

and on the Preview and Response tabs, i see:

{"echo":"testdata"}

However, if I then throw an actual error into the script (which is more often than not during this learning period!) and test the page out in Chrome, the network tab shows the call being made

Request URL:http://localhost/test.py?data=somedata
Request Method:GET
Status Code:500 Internal Server Error

Query String Parameters: (view URL encoded)
    data:'somedata'

But, if I click on preview, It shows:

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, you@example.com and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.

Apache/2.2.21 (Unix) DAV/2 mod_wsgi/3.3 Python/2.6.7 Server at localhost Port 80

My question is whether or not it’s possible to use this window to show a stack trace or any information that would help me diagnose problems. I’m doing all my debugging by trial-and-error at the moment, other than that loving every second of Python.

Would anybody be able to point me in the right direction?

EDIT: This page:

http://code.google.com/p/modwsgi/wiki/DebuggingTechniques

has a solution under the heading “Error Catching Middleware” but their example isn’t working for me.

  • 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-06-02T21:01:38+00:00Added an answer on June 2, 2026 at 9:01 pm

    Try writing your code to be tolerant of not being given a QUERY_STRING. The following will fail if there isn’t one.

    data = environ['QUERY_STRING'].split('=')[1])
    

    In general it is always better to use some sort of framework which ensures little things like this may not be a problem.

    See Flask as a good example of a small micro framework.

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to render a haml file in a javascript response like so:
I have some data like this: 1 2 3 4 5 9 2 6
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I have a jquery bug and I've been looking for hours now, I can't
I have just tried to save a simple *.rtf file with some websites and
I would like to count the length of a string with PHP. The string
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

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.