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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T16:12:47+00:00 2026-06-13T16:12:47+00:00

I’m using the cgi module to handle form input data, but I would like

  • 0

I’m using the cgi module to handle form input data, but I would like to have the form and the processing in separate files (modules?). Is there a way to pass the POSTed information from the HTML to the processing file?

I’m not using any frameworks and would like to keep this as simple as possible. I know that I can get this to work by having the HTML printed in the python file, but I’d like to keep the two separate.

Here’s the real problem code:

<form action="processes/process.py" method="post">
            <div id="name1" class="formData"><label for="">First name:</label><input name="firstName" type="text" id="firstName" /></div>
            <div id="name2" class="formData"><label>Last name:</label><input name="lastName" type="text" id="lastName" /></div>
            <div id="email" class="formData"><label>Email address:</label><input name="emailAddress" type="text" id="emailAddress" /></div>
            <div id="mailAddress" class="formData"><label>Mailing address:</label><input name="physicalAddress" type="textarea" id="physicalAddress" /></div>

            <input type="submit" value="Submit" onClick="T_validateForm('firstName','','R','lastName','','R','EmailAddress','','RisEmail');return document.T_returnValue">
        </form>

I can have this printed in my process.py file and change the action, but I would like this form code to be separate from the code I will use to manage and distribute the information form the form. I need to pass the data to process.py

I’m trying to get the data in the python code here:

form = cgi.FieldStorage()
firstName = form['firstName'].value
lastName = form['lastName'].value
emailAddress = form['emailAddress'].value
physicalAddress = form['physicalAddress'].value

I know that in php form is replaced by $_POST. Is there a similar identifier in python? form works when they’re in the same file, but it seems that there should be some way to tell python to get the data from the HTML POST. I thought that cgi.FieldStorage() did that, but it doesn’t work. Should I be passing parameters to cgi.FieldStorage()?

  • 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-13T16:12:48+00:00Added an answer on June 13, 2026 at 4:12 pm

    The question is pretty broad, altough I understand separating content, logic and presentation is what you’re after.

    Are you maybe looking for a templating language like Jinja, Mako or Chameleon? Or a simple form generation and validation library like FormEncode? Those can be just as easily used with or without a web framework.

    As opposed to PHP, in Python CGI is hardly ever used. We use WSGI instead, or web frameworks (micro to large) with their own request model and form handling libraries. Doing it yourself with CGI could be an educational example, but you’ll almost always be better of using an existing framework even for small web apps. Could be a micro framework like bottle.

    If it’s unclear to you how to factor out code into several Python modules, I would ask a new question about that (probably best with no ties to web development whatsoever). Additionally, I’d evaluate a couple templating languages for Python, and possibly a few micro frameworks.

    • 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&#8217;Everest What PHP function
I have thousands of HTML files to process using Groovy/Java and I need to
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I have a French site that I want to parse, but am running into
I would like to run a str_replace or preg_replace which looks for certain words
This could be a duplicate question, but I have no idea what search terms
I would like to count the length of a string with PHP. The string
I have a text area in my form which accepts all possible characters from
I want to construct a data frame in an Rcpp function, but when I
I am using Paperclip to handle profile photo uploads in my app. They upload

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.