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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T06:48:04+00:00 2026-05-26T06:48:04+00:00

I have some JSON scripts that I plan on parsing on the site and

  • 0

I have some JSON scripts that I plan on parsing on the site and then allowing the clients to edit them through my interface (to later be loaded and parsed once again for display). Problem is, Javascript doesn’t have access to writing to the file system. I’ve already got a system for reading the JSON files using Javascript (and jQuery). Now, I’ve heard I can use CGI to save the data later. Can somebody give me some references and in depth explanations? I’ve read a bit about CGI in general but nothing specific.

Thanks for any help!

  • 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-26T06:48:05+00:00Added an answer on May 26, 2026 at 6:48 am

    CGI is a way for servers to interface with scripts. Pretty much, you just set up the server to execute a file, and it will execute it with several environment variables set and POST data fed to its standard input. The script should output the headers for the page, followed by the content.

    CGI scripts can be written in many different languages. Perl is well-known for CGI scripts; it has documentation on it here. Python has a cgi module to deal with CGI. Ruby has a CGI package as well.

    Here’s a quick CGI script written in Python that writes to a file. You’ll probably want to modify it or use it as a reference rather than using it as-is:

    #!/usr/bin/env python
    import os
    import os.path
    import sys
    import json
    import cgi
    # You'll probably want to remove or alter
    # the following line for production.
    import cgitb; cgitb.enable()
    
    def bad_request():
        print "Status: 400 Bad Request"
        print "Content-Type: application/json"
        print ""
        json.dump({'success': False}, sys.stdout)
        sys.exit(0)
    
    assert 'REQUEST_METHOD' in os.environ
    if os.environ['REQUEST_METHOD'] != 'POST':
        bad_request()
    
    form = cgi.FieldStorage()
    if 'data' not in form:
        bad_request()
    
    filename = os.path.join(os.path.dirname(__file__), "some_file.json")
    with open(filename, "wb") as f:
        f.write(form['data'].value)
    
    print "Content-Type: application/json"
    print ""
    json.dump({'success': True}, sys.stdout)
    

    If you POST to it with a data parameter, it will save that data into some_file.json in the same directory as itself.

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

Sidebar

Related Questions

I have an jQuery JSON request, that loads some JSON from another server (ex.
I have a spring action that I am rendering some json from the controller,
I have an iPhone app that uses the json-framework . I moved some of
After searching through some existing libraries for JSON, I have finally ended up with
I'm trying to generate a JSON response that includes some HTML. Thus, I have
I have some PHP script that logs in and returns a JSON array with
I have some JSON returned to the browser like this product: { Title: School
I have some json files with 500MB. If I use the "trivial" json.load() to
I have a website where an ajax call will get some Json data from
I am trying to output some Java objects as JSON, they have List properties

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.