- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to write first Hello World program using CGI programming in Python?
First CGI Program
A 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 - First CGI Program</title>' print '</head>' print '<body>' print '<h2>Hello Word! This is my first CGI program</h2>' print '</body>' print '</html>'
Output
If you click hello.py, then this produces the following output −
Hello Word! This is my first CGI program
- Related Articles
- How to write "Hello, World!" program in JavaScript?
- How to write "Hello World" Program in C++?
- Hello World in Dart Programming
- How to print "Hello World!" using Python?
- How to write "Hello World" in C#?
- Python Program to Print Hello world
- Beginning Java programming with Hello World
- Beginning C# programming with Hello World
- Write a program to display "Hello World" in react native?
- First Hello World project in Arduino
- Beginning Java programming with Hello World Example
- First CGI Program in Python
- C++ "Hello, World!" Program
- Hello World Program in Java
- Hello World program in Kotlin

Advertisements