Commits

Shinya Okano committed 5fa510a

サンプルサーバを追加

  • Participants
  • Parent commits cd10a06

Comments (0)

Files changed (3)

sample/fapws3/custom_base.py

+import StringIO
+
+from fapws.base import *
+from fapws.base import Environ as BaseEnviron
+
+class Environ(BaseEnviron):
+    def __init__(self, *arg, **kw):
+        super(Environ, self).__init__(*arg, **kw)
+        self['wsgi.errors'] = StringIO.StringIO()
+        self['wsgi.input'] = StringIO.StringIO()

sample/fapws3/run.py

+import fapws._evwsgi as evwsgi
+import time
+import sys
+sys.setcheckinterval(100000) # since we don't use threads, internal checks are no more required
+
+import os
+from apphosting.handler import Handler
+from apphosting.config import Config
+
+import custom_base
+
+handler = Handler(Config({
+    'pool_max_runners': 5,
+    'provider_appdir': os.path.join(os.path.dirname(__file__), '../../tests'),
+    'router_domain': 'example.com'
+}))
+
+def start():
+    evwsgi.start("0.0.0.0", "8080")
+
+    evwsgi.set_base_module(fapws_base)
+
+    evwsgi.wsgi_cb(('', handler))
+
+    evwsgi.set_debug(0)
+    evwsgi.run()
+
+    handler.free()
+
+if __name__=="__main__":
+    start()

sample/wsgiref/run.py

+from wsgiref.simple_server import make_server
+
+from StringIO import StringIO
+import os
+from apphosting.handler import Handler
+from apphosting.config import Config
+
+def start():
+    handler = Handler(Config({
+        'pool_max_runners': 5,
+        'provider_appdir': os.path.join(os.path.dirname(__file__), '../../tests'),
+        'router_domain': 'example.com'
+    }))
+
+    httpd = make_server('0.0.0.0', 8080, handler)
+    httpd.serve_forever()
+
+    hadnler.free()
+
+if __name__=="__main__":
+    start()