def main(): '''A simple server startup if module is called directly''' # port = 8080 # host = '0.0.0.0' from optparse import OptionParser parser = OptionParser() parser.add_option("--host", default="0.0.0.0", dest="host", help="host ip to run") parser.add_option("-p", "--port", dest="port", default=8080, help="the port to run on.") (options, args) = parser.parse_args() try: import paste from paste import httpserver # use this for the interactive debugger from paste.evalexception import EvalException # add the static server component from static_serve import static_serve my_app = static_serve(app, path='public') httpserver.serve(my_app, host=options.host, port=options.port) sys.exit(1) except ImportError: pass from wsgiref.simple_server import make_server # add the static server component from static_serve import static_serve my_app = static_serve(app, path='public') httpd = make_server(options.host, options.port, my_app) print "Serving on port {0}...".format(options.port) httpd.serve_forever() sys.exit(1)
def main(): '''A simple server startup if module is called directly''' # port = 8080 # host = '0.0.0.0' from wsgiref.simple_server import make_server from optparse import OptionParser from static_serve import static_serve import logging log = logging.getLogger(__name__) parser = OptionParser() parser.add_option("--host", default="0.0.0.0", action="store", type="string", dest="host", help="host ip to run") parser.add_option("-p", "--port", action="store", type="int", dest="port", default=8080, help="the port to run on.") (options, args) = parser.parse_args() # add the static server component my_app = static_serve(app, path='public') log.debug("Serving on {0}:{1}...".format(options.host, options.port)) httpd = make_server(options.host, options.port, my_app) httpd.serve_forever() sys.exit(1)
def main(): '''A simple server startup if module is called directly''' from paste.evalexception import EvalException # a stupid static file server to serve data in 'content' from static_serve import static_serve from paste.httpserver import serve # Dispatcher is a rock-dumb URL path comarison to call the three motini functions app = static_serve(path="content") app = Dispatcher(app) app = EvalException(app) serve(app, '0.0.0.0', 8000, socket_timeout=2)
from jobskillchallenge.app.models.user import User from static_serve import static_serve # The main application pipeline # Include all WSGI middleware here. The order of # web transaction will flow from the bottom of this list # to the top, and then back out. The pybald Router # is usually the first item listed. # ---------------------------------- app = Router(routes=my_project.app.urls.map) app = UserManager(app, user_class=User) app = SessionManager(app, session_class=Session) app = DbMiddleware(app) app = ErrorMiddleware(app, error_controller=None) app = EndPybaldMiddleware(app) app = static_serve(app, path='public') # ---------------------------------- # ↑↑↑ ↓↓↓ # ↑↑↑ ↓↓↓ # Request Response # apache / mod_wsgi looks for 'application' application = app # called directly enable the interactive debugger # requires python paste be installed def main(): '''A simple server startup if module is called directly''' # port = 8080 # host = '0.0.0.0'