IT News & Technology update

Provide comprehensive update related to Computer, technology, software, anti virus and another electric device

Running Python Script on Windows

Written by IT News on 9:57 AM

TIPS AND TRICKS

Python is a free and interpreted object-oriented programming allows you to create any type of application compatible with all operating systems.
You can deploy a stand-alone application or CGI scripts. There are many web servers, which provide support for the deployment of Python scripts.

If you use the Apache web server on Windows platform, you have a lot of options for creating a certain configuration, which enables you to run Python scripts via CGI. Configuring Apache web server can be done by editing the httpd.conf file.

First, you need to download and install the latest Python for Windows distribution. It was recommended to install it directly to the root of the c: drive to the executable file (python.exe) located at: \ Python directory. This file can be found in httpd.conf apache installed in a folder named conf.

This file contains the usual Apache configuration directives that can be included in removing a line. In the case of Python CGI script, in accordance with the directive of the AddHandler http.conf file shall have the following structure:

AddHandler cgi-script .cgi .py .pl

In this way, Apache web server will treat Python and Perl files as CGI scripts. The second modification that must be made to Apache configuration file is the specification of the location of your cgi-bin directory by adding the full path to it in the next line (you must replace C:/apache/cgi-bin with the path of your cgi-bin directory):


ScriptAlias /cgi-bin/ "c:/apache/cgi-bin/"
#!c:/Python/python.exe -u



print "Content-type: text/html"
print

print "

The First Python Script On Server Side

"
print "

The sum of two numbers evaluation

"
print "3+5 = ",3+5


You notice that the script will output HTML code from the 4 and 5 lines, and to assess the sum of two numbers in a row 6 and display it. The first line (#! C: / Python24/python.exe- a) shows the path to the script interpreter, and the near-parameter specifies interpreter unbuffered run, in order to avoid errors. In the second line scenario points to a web browser type of data that must be provided.

This is only one simple scenario, but its purpose is to allow you to check your own Apache server. If you want to change a Python script Apache web server on Windows to check the influence of different variables, this method Apache server configuration, support for Python CGI scripts can save a lot of time.

Related Posts by Categories



Widget by Hoctro | Jack Book
  1. 0 comments: Responses to “ Running Python Script on Windows ”

Search This Blog

Ads and Sponsored by:



Want to subscribe?

Subscribe in a reader.