Rajendra Dharmkar has Published 784 Answers

How to write first Hello World program using CGI programming in Python?

Rajendra Dharmkar
Published on 31-Jan-2018 07:16:07
First CGI ProgramA CGI script called hello.py is kept in /var/www/cgi-bin directory and it has following content. Before running the CGI program, we make sure we change the mode of file using chmod 755 hello.py UNIX command to make file executable.Example#!/usr/bin/python print "Content-type:text/html\r\n\r\n" print '<html>' print '<head>' print '<title>Hello Word ... Read More

What are the modules required for CGI programming in Python?

Rajendra Dharmkar
Published on 31-Jan-2018 07:11:50
Python's cgi module is usually the starting place in writing CGI programs in Python. The main purpose of the cgi module is to extract the values passed to a CGI program from an HTML form. Mostly one interacts with CGI applications through an HTML form. One fills out some values ... Read More

How to pass Drop Down Box Data to Python CGI script?

Rajendra Dharmkar
Published on 31-Jan-2018 05:44:29
Passing Drop Down Box Data to CGI ProgramDrop Down Box is used when we have many options available but only one or two will be selected.Here is example HTML code for a form with one drop down box −<form action = "/cgi-bin/dropdown.py" method = "post" target = "_blank"> ... Read More

How to pass Text Area Data to Python CGI script?

Rajendra Dharmkar
Published on 31-Jan-2018 05:42:32
Passing Text Area Data to CGI ProgramTEXTAREA element is used when multiline text has to be passed to the CGI Program.Here is example HTML code for a form with a TEXTAREA box −<form action = "/cgi-bin/textarea.py" method = "post" target = "_blank"> <textarea name = "textcontent" cols = "40" rows ... Read More

How to pass Checkbox Data to Python CGI script?

Rajendra Dharmkar
Published on 31-Jan-2018 05:40:24
Passing Checkbox Data to CGI ProgramCheckboxes are used when more than one option is required to be selected.Here is example HTML code for a form with two checkboxes −<form action = "/cgi-bin/checkbox.cgi" method = "POST" target = "_blank"> <input type = "checkbox" name = "maths" value = "on" /> Maths ... Read More

How to pass Radio Button Data to Python CGI script?

Rajendra Dharmkar
Published on 31-Jan-2018 05:35:30
Passing Radio Button Data to CGI ProgramRadio Buttons are used when only one option is required to be selected.Here is example HTML code for a form with two radio buttons −<form action = "/cgi-bin/radiobutton.py" method = "post" target = "_blank"> <input type = "radio" name = "subject" value = "maths" ... Read More

How to do CGI programming in Python?

Rajendra Dharmkar
Published on 30-Jan-2018 12:14:32
CGI ProgrammingThe Common Gateway Interface, or CGI, is a set of standards that define how information is exchanged between a web server and a custom script.Python CGI Programming is about running our Python Scripts on the web. For that we have to learn how Python can be executed as a ... Read More

When are python objects candidates for garbage collection?

Rajendra Dharmkar
Published on 30-Jan-2018 02:30:57
A python object or variable will be eligible for garbage collection as soon as all references to it go out of scope or are manually deleted (del x). We would have to presume there were no references to the object anywhere else for it to be garbage collected.

How to encode custom python objects as BSON with Pymongo?

Rajendra Dharmkar
Published on 30-Jan-2018 02:11:29
To encode custom python objects as BSON with Pymongo, you have to write a SONManipulator. From the docs:SONManipulator instances allow you to specify transformations to be applied automatically by PyMongo.from pymongo.son_manipulator import SONManipulator class Transform(SONManipulator):   def transform_incoming(self, son, collection):     for (key, value) in son.items():       ... Read More

Do you think garbage collector can track all the Python objects?

Rajendra Dharmkar
Published on 30-Jan-2018 02:05:51
Python uses two techniques to clean up garbage. One is reference counting, which affects all objects but which can't clean up objects that directly or indirectly refer to each other. That's where the actual garbage collector comes in: python has the gc module, which searches for cyclic references in objects ... Read More
Advertisements