[pypy-commit] jitviewer default: make it work more like wsgi app

fijal noreply at buildbot.pypy.org
Sat Jul 21 19:11:13 CEST 2012


Author: Maciej Fijalkowski <fijall at gmail.com>
Branch: 
Changeset: r203:a3786d621050
Date: 2012-07-21 19:10 +0200
http://bitbucket.org/pypy/jitviewer/changeset/a3786d621050/

Log:	make it work more like wsgi app

diff --git a/_jitviewer/app.py b/_jitviewer/app.py
--- a/_jitviewer/app.py
+++ b/_jitviewer/app.py
@@ -193,7 +193,7 @@
             orig___init__(self2, *args, **kwds)
         BaseServer.__init__ = __init__
 
-def main():
+def main(run_app=True):
     if not '__pypy__' in sys.builtin_module_names:
         print "Please run it using pypy-c"
         sys.exit(1)
@@ -223,14 +223,17 @@
     app.debug = True
     app.route('/')(server.index)
     app.route('/loop')(server.loop)
-    def run():
-        app.run(use_reloader=False, host='0.0.0.0', port=port)
+    if run_app:
+        def run():
+            app.run(use_reloader=False, host='0.0.0.0', port=port)
 
-    if server_mode:
-        run()
+        if server_mode:
+            run()
+        else:
+            url = "http://localhost:%d/" % port
+            run_server_and_browser(app, run, url, filename)
     else:
-        url = "http://localhost:%d/" % port
-        run_server_and_browser(app, run, url, filename)
+        return app
 
 def run_server_and_browser(app, run, url, filename):
     try:


More information about the pypy-commit mailing list