/examples/web/singleclickandrun.py
Python | 35 lines | 31 code | 3 blank | 1 comment | 0 complexity | 33e9b7967411ce03f20085b970def73e MD5 | raw file
1#!/usr/bin/env python 2 3import webbrowser 4 5from circuits.web import Server, Controller 6 7HTML = """\ 8<html> 9 <head> 10 <title>An example application</title> 11 </head> 12<body> 13 <h1>This is my sample application</h1> 14 Put the content here... 15 <hr> 16 <a href="/exit">Quit</a> 17</body> 18</html> 19""" 20 21 22class Root(Controller): 23 24 def index(self): 25 return HTML 26 27 def exit(self): 28 raise SystemExit(0) 29 30app = Server(("0.0.0.0", 8000)) 31Root().register(app) 32app.start() 33 34webbrowser.open("http://127.0.0.1:8000/") 35app.join()