473,594 Members | 2,713 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

simple script using CGIHTTPServer?

Let's say I've got the following little script called test1.py:

print "Content-type: text/html\n\n"
print "<html><bod y>"
print "<h1>Hello World</h1>"
print "</body></html>"

I want to run a script that takes advantage of CGIHTTPServer so that I
can send a browser to http://localhost:8081/test1.py and see the
results of the script above. What's the shortest such script that I
need to make this work? After some web searching, I found
http://manatee.mojam.com/~skip/python/web-server.py and
http://www.doc.ic.ac.uk/~tb100/proje.../standalone.py but
couldn't get either to work.

thanks,

Bob
Jul 18 '05 #1
1 3548
"philregion " <bo**********@l exisnexis.com> wrote:
Let's say I've got the following little script called test1.py:

print "Content-type: text/html\n\n"
print "<html><bod y>"
print "<h1>Hello World</h1>"
print "</body></html>"

I want to run a script that takes advantage of CGIHTTPServer so that I
can send a browser to http://localhost:8081/test1.py and see the
results of the script above. What's the shortest such script that I
need to make this work?


You don't need a script at all. Create a directory called cgi-bin. Copy
your script to that directory. From the directory that CONTAINS cgi-bin,
run this:

python /python23/lib/CGIHTTPServer.p y 8081

adjusting the path accordingly.

Send your browser to http://localhost:8081/cgi-bin/test1.py.
--
- Tim Roberts, ti**@probo.com
Providenza & Boekelheide, Inc.
Jul 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
3243
by: Preston Crawford | last post by:
I'm looking to quickly get a photo album online. Very simple, thumbnails, a few pages, maybe a description, but hopefully a small script that's easy to edit and work into my existing site. I know about hot scripts, etc. but I was wondering if any one could recommend one? Secondly, I also want to setup a journal. It's not really a "blog" although I guess blog software may work. But it isn't going to be a message board or anything like...
2
8059
by: Dfenestr8 | last post by:
Hi. I'm just a hobbyist and I like mucking around with cgi scripts. Here's the script I've been using...... >#! /usr/bin/python > >import BaseHTTPServer >import CGIHTTPServer
3
2404
by: vincent wehren | last post by:
Hi, as a small capabilities demo I coded the piece below to show how to use Python for cgi'ing on localhost and it more or less does the trick :-). However, I when I freeze it with py2exe, starting the resulting exe fires up the server allright, but fails execute cgi commands correctly (i.e. the expected output - let's say from cgi.test()) - is no longer emitted to the browser...). Is there some py2exe-magic I need to do that I don't...
2
11243
by: Gelo Ilzi | last post by:
I'm trying to implement a very simple http server with cgi functionality. The code is simple: import CGIHTTPServer, BaseHTTPServer httpd = BaseHTTPServer.HTTPServer(('',8000), CGIHTTPServer.CGIHTTPRequestHandler) httpd.serve_forever() I've created a subdir 'cgi-bin' which contains a python script. Now when I enter this directory, i.e., go to the url http://localhost:8000/cgi-bin/ my
6
2863
by: pxlpluker | last post by:
i was looking at twisted but it appears to be WAY beyond my megar skills at this point. so i think CGIHTTPServer will fit my needs if it is pretty stable. I have a small python cgi that i was building and i had this great idea of having the cgi server kinda rolled into it for various portability reasons and maybe some future features that would not have apache to realy on. Fred
9
12325
by: Pete | last post by:
Does anyone have a simple html vbscript or other type of snippet they can share that appends a record to a access database via ADO or DAO? I would like to allow users that don't have Microsoft Access a way of adding records to a access database from a simple web page. I don't want to have to setup ODBC or anything like that I just want to put the web page on the network for anyone to access. Most of the users would use the local access...
0
1877
by: 42 | last post by:
I implemented a simple class inherited from Page to create a page template. It simply wraps some trivial html around the inherited page, and puts the inherited page into a form. The problem I have run into is that the emitted html at the end of the process is slightly different and doesn't work. Please don't be put off by all the source code. All the guts are in this first base class, and it doesn't do much. The rest is trivial...
3
3484
by: sophie_newbie | last post by:
Is there any way that I can pass cgi parameters to my script locally, before i upload it to the webserver, so that i can debug it. Normally I would pass parameters like this: www.webserver.com/script.cgi?TERM1=hello&FIELD1=TTL&TERM2=goodby&FIELD2=GOVT The problem is that I get errors that do not show up when I run the script locally and I do not have access to the error logs.
24
6313
by: firstcustomer | last post by:
Hi, Firstly, I know NOTHING about Javascript I'm afraid, so I'm hoping that someone will be able to point me to a ready-made solution to my problem! A friend of mine (honest!) is wanting to have on his site, a Javascript Calculator for working out the cost of what they want, for example: 1 widget and 2 widglets = £5.00
0
7946
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
7876
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8251
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8372
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8234
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6654
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
5739
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
3859
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
3897
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.