twisted server

Mikie thephantom6969 at hotmail.com
Mon Jun 15 13:02:54 EDT 2009


I am setting up a simple twisted server looks like this
___________________________________________________-
It will respond on port 8007 of the local host
With a predefined greeting.
"""
print greeting

from twisted.internet.protocol import Protocol, Factory
from twisted.internet import reactor

class QOTD(Protocol):
	def connectionMade(self):
		self.transport.write("""
<!DOCTYPE html PUBLIC>
<html>
	<head>
		<title>Twisted TCP Server Example</title>
	</head>
	<body>
		<h1>HELLO WORLD!</h1>
		<pre>
This is a TCP/IP Server written in Python using
the Twisted networking framework.

Further instruction can be found here:
<a href="http://twistedmatrix.com/projects/core/documentation/howto/
servers.html">
	Twisted Documentation: Writing Servers
</a>

This server will respond on port 8007 of the local host
With a predefined greeting.
		</pre>
	</body>
</html>""")
		self.transport.loseConnection()

# Then lines are Twisted magic:
factory = Factory()
factory.protocol = QOTD

# Running under :8007
# Should be > :1024
reactor.listenTCP(8007, factory)
reactor.run()
______________________________________________--
I would like to have an image loaded in the html page, but when I use
<img src="image.gif"> the port is inserted and the image will not
load.  Is there a way to load the image?
Thanx



More information about the Python-list mailing list