/examples/web/singleclickandrun.py

https://bitbucket.org/prologic/circuits/ · Python · 35 lines · 25 code · 9 blank · 1 comment · 0 complexity · 33e9b7967411ce03f20085b970def73e MD5 · raw file

  1. #!/usr/bin/env python
  2. import webbrowser
  3. from circuits.web import Server, Controller
  4. HTML = """\
  5. <html>
  6. <head>
  7. <title>An example application</title>
  8. </head>
  9. <body>
  10. <h1>This is my sample application</h1>
  11. Put the content here...
  12. <hr>
  13. <a href="/exit">Quit</a>
  14. </body>
  15. </html>
  16. """
  17. class Root(Controller):
  18. def index(self):
  19. return HTML
  20. def exit(self):
  21. raise SystemExit(0)
  22. app = Server(("0.0.0.0", 8000))
  23. Root().register(app)
  24. app.start()
  25. webbrowser.open("http://127.0.0.1:8000/")
  26. app.join()