~ubuntu-branches/ubuntu/karmic/pypy/karmic

« back to all changes in this revision

Viewing changes to pypy/translator/js/tutorial/step1.py

  • Committer: Bazaar Package Importer
  • Author(s): Alexandre Fayolle
  • Date: 2007-04-13 09:33:09 UTC
  • Revision ID: james.westby@ubuntu.com-20070413093309-yoojh4jcoocu2krz
Tags: upstream-1.0.0
ImportĀ upstreamĀ versionĀ 1.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env python
 
2
"""
 
3
 
 
4
This is simple all-in-one self-containing server,
 
5
which just shows almost-empty HTML page
 
6
 
 
7
"""
 
8
 
 
9
# here we import server, which is derivative of
 
10
# BaseHTTPServer from python standard library
 
11
from pypy.translator.js.lib import server
 
12
 
 
13
# We create handler, which will handle all our requests
 
14
class Handler(server.TestHandler):
 
15
 
 
16
    def index(self):
 
17
        # provide some html contents
 
18
        return "<html><head></head><body><p>Something</p></body></html>"
 
19
    # this line is necessary to make server show something,
 
20
    # otherwise method is considered private-only
 
21
    index.exposed = True
 
22
 
 
23
if __name__ == '__main__':
 
24
    # let's start our server,
 
25
    # this will create running server instance on port 8000 by default,
 
26
    # which will run until we press Control-C
 
27
    server.create_server(handler=Handler).serve_forever()