Diesel-based (greenlet) WSGI-HTTP server.
	
	As a minor note, this is crazy. Diesel includes Flask, too.
15017
def serve(application, host='127.0.0.1', port=8080):
	
	
	# Instantiate the server with a host/port configuration and our application.
	WSGIApplication(application, port=int(port), iface=host).run()
263726
def main():
    
    try:
        # Get the `src` directory's absolute path
        src_path = os.path.dirname(
            # `aoiklivereload` directory's absolute path
            os.path.dirname(
                # `demo` directory's absolute path
                os.path.dirname(
                    # This file's absolute path
                    os.path.abspath(__file__)
                )
            )
        )

        # If the `src` directory path is not in `sys.path`
        if src_path not in sys.path:
            # Add to `sys.path`.
            #
            # This aims to save user setting PYTHONPATH when running this demo.
            #
            sys.path.append(src_path)

        # Import reloader class
        from aoiklivereload import LiveReloader

        # Create reloader
        reloader = LiveReloader()

        # Start watcher thread
        reloader.start_watcher_thread()

        # Server host
        server_host = '0.0.0.0'

        # Server port
        server_port = 8000

        # Get message
        msg = '# ----- Run server -----\nHost: {}\nPort: {}'.format(
            server_host, server_port
        )

        # Print message
        print(msg)

        # Create Flask app
        flask_app = flask.Flask(__name__)

        # Create request handler
        @flask_app.route('/')
        def hello_handler():  # pylint: disable=unused-variable
            """
            Request handler.

            :return:
                Response body.
            """
            # Return response body
            return 'hello'

        # Run server
        flask_app.run(
            host=server_host,
            port=server_port,
            # Disable Flask's reloader
            debug=False,
        )

    # If have `KeyboardInterrupt`
    except KeyboardInterrupt:
        # Not treat as error
        pass
1105280
function makeServeMiddleware(/* config */) {
  return function handle(req, resp, next) {
    if (/^\/.*\.css$/.test(req.url)) {
      resp.end("");
    }
    else {
      next();
    }
  };
}
187256
def setup(self, environ):
        '''
        '''
        request = wsgi_request(environ)
        cfg = request.cache.cfg
        loop = request.cache._loop
        self.store = create_store(cfg.data_store, loop=loop)
        pubsub = self.store.pubsub(protocol=Protocol())
        channel = '%s_webchat' % self.name
        ensure_future(pubsub.subscribe(channel), loop=loop)
        return WsgiHandler([Router('/', get=self.home_page),
                            WebSocket('/message', Chat(pubsub, channel)),
                            Router('/rpc', post=Rpc(pubsub, channel),
                                   response_content_types=JSON_CONTENT_TYPES)],
                           [AsyncResponseMiddleware,
                            GZipMiddleware(min_length=20)])
1316326
def setup_app(app, cfg):
    
    # Set up app_host and app_port in case that we are running
    # under reverse proxy setup, otherwise they default to
    # config.host and config.port.
    if (cfg.app_host and cfg.app_port):
        logging.warning("Reverse proxy for service at http://%s:%d/ ..." % (cfg.host, cfg.port))
        app.wsgi_app = ReverseProxied(app.wsgi_app, cfg.host)
    elif (cfg.app_host or cfg.app_port):
        logging.critical("Must specify both app-host and app-port for reverse proxy configuration, aborting")
        sys.exit(1)
    else:
        cfg.app_host = cfg.host
        cfg.app_port = cfg.port
    logging.warning("Setup server on http://%s:%d/ ..." % (cfg.app_host, cfg.app_port))
    return(app)
586297
def run(self, app):
        """"""
        GlimLog.info('Glim server started on %s environment' % self.args.env)
        try:
            kwargs = Config.get('app.server.options')
            run(app.wsgi,
                host=Config.get('app.server.host'),
                port=Config.get('app.server.port'),
                debug=Config.get('app.server.debugger'),
                reloader=Config.get('app.server.reloader'),
                server=Config.get('app.server.wsgi'),
                **kwargs)
        except Exception as e:
            print(traceback.format_exc())
            exit()
768252
def host(environ):  # pragma: no cover
    

    url = environ['wsgi.url_scheme'] + '://'

    if environ.get('HTTP_HOST'):
        url += environ['HTTP_HOST']
    else:
        url += environ['SERVER_NAME']

        if environ['wsgi.url_scheme'] == 'https':
            if environ['SERVER_PORT'] != '443':
                url += ':' + environ['SERVER_PORT']
        else:
            if environ['SERVER_PORT'] != '80':
                url += ':' + environ['SERVER_PORT']

    return url + quote(environ.get('SCRIPT_NAME', ''))
515013
def _base_environ(self, **request):
        '''
            
        '''
        # This is a minimal valid WSGI environ dictionary, plus:
        # - HTTP_COOKIE: for cookie support,
        # - REMOTE_ADDR: often useful, see #8551.
        # See http://www.python.org/dev/peps/pep-3333/#environ-variables

        environ = {
            'HTTP_COOKIE': self.cookies.output(header='', sep='; '),
            'PATH_INFO': str('/'),
            'REMOTE_ADDR': str('127.0.0.1'),
            'REQUEST_METHOD': str('GET'),
            'SCRIPT_NAME': str(''),
            'SERVER_NAME': str('localhost'),
            'SERVER_PORT': str('8000'),
            'SERVER_PROTOCOL': str('HTTP/1.1'),
            'wsgi.version': (1, 0),
            'wsgi.url_scheme': str('http'),
            'wsgi.input': FakePayload(b''),
            'wsgi.errors': self.errors,
            'wsgi.multiprocess': True,
            'wsgi.multithread': True,
            'wsgi.run_once': False,
        }
        environ.update(self.defaults)
        environ.update(request)
        return environ
94302
def wsgi_handler(event, context, app, logger):
    

    environ = build_wsgi_environ_from_event(event)
    wsgi_status = []
    wsgi_headers = []

    logger.info('Processing {} request'.format(environ['REQUEST_METHOD']))

    def start_response(status, headers):
        if len(wsgi_status) or len(wsgi_headers):
            raise RuntimeError('start_response called more than once!')
        wsgi_status.append(status)
        wsgi_headers.append(headers)

    resp = list(app(environ, start_response))
    proxy = {'statusCode': int(wsgi_status[0].split()[0]),
             'headers': {h[0]: h[1] for h in wsgi_headers[0]},
             'body': b''.join(resp).decode('utf-8')}

    logger.info("Returning {}".format(proxy['statusCode']),
                http_status=proxy['statusCode'])

    return proxy
206755
def devserver(arguments):
    """"""
    import coil.web
    if coil.web.app:
        port = int(arguments['--port'])
        url = 'http://localhost:{0}/'.format(port)
        coil.web.configure_url(url)
        coil.web.app.config['DEBUG'] = True

        if arguments['--browser']:
            webbrowser.open(url)

        coil.web.app.logger.info("Coil CMS running @ {0}".format(url))
        coil.web.app.run('localhost', port, debug=True)
        return 0
    else:
        print("FATAL: no conf.py found")
        return 255
22980
function server() {
  // TODO: Show require express error
  var express = require('express')
    , app = express();

  app.configure(function() {
    app.use(express.static(siteBuilder.outputRoot));
    app.use(express.errorHandler({ dumpExceptions: true, showStack: true }));
  });

  // Map missing trailing slashes for posts
  app.get('*', function(req, res) {
    var postPath = siteBuilder.outputRoot + req.url + '/';
    // TODO: Security
    if (req.url.match(/[^/]$/) && existsSync(postPath)) {
      res.redirect(req.url + '/');
    } else {
      res.send('404');
    }
  });

  app.listen(siteBuilder.config.port);
  log.info('Listening on port', siteBuilder.config.port);
}
787863
function serveRoutes(server) {
    var app = server.app;
    var generator = server.generator;

    // route browserscripts, including builtins
    u.each(self.scripts, function(script) {
      var handler = browserify(script.path, script.opts);
      if (script.delay) {
        var delayed = function(req, res) {
          debug(req.path, 'waiting', script.delay);
          setTimeout(function() {
            debug(req.path, 'done waiting', script.delay);
            handler(req, res);
          }, u.ms(script.delay));
        };
      }
      app.get(script.route, delayed || handler);
    });

    // editor api
    if (opts.editor) {
      app.post('/pub/_files', function(req, res) {
        generator.serverSave(req.body, req.user, function(err, results) {
          if (err) return res.status(500).send(err);
          res.status(200).send(results);
        });
      });
      app.get('/pub/_opts.json', function(req, res) {
        res.set('Cache-Control', 'no-cache');
        res.send(serializeOpts(server.generator));
      });
    }

    // admin api
    app.get('/admin/flushCaches', function(req, res) {
      generator.flushCaches(function(err, results) {
        if (err) return res.status(500).send(err);
        res.status(200).send(results);
      });
    });

    app.get('/admin/reloadSources', function(req, res) {
      res.send(generator.reloadSources(req.query.src));
    });

    app.get('/admin/outputPages', function(req, res) {
      generator.outputPages(req.query.output, function(err, results) {
        if (err) return res.status(500).send(err);
        res.status(200).send(u.flatten(results));
      });
    });

    app.get('/admin/logPages', function(req, res) {
      res.send(generator.logPages());
    });

    app.get('/admin/reload', function(req, res) {
      generator.reload();
      res.status(200).send('OK');
    });
  }
733045
function createServer() {
  function app(req, res, next){ app.handle(req, res, function(){
    res.end("", 'utf8');
  }); }
  merge(app, proto);
  merge(app, EventEmitter.prototype);
  app.route = '/';
  app.stack = [];
  return app;
}
181898
def fileserver(opts, backends):
    '''
    
    '''
    return LazyLoader(_module_dirs(opts, 'fileserver'),
                      opts,
                      tag='fileserver',
                      whitelist=backends,
                      pack={'__utils__': utils(opts)})
971328
def make_wsgi_app(matching, not_found_app=not_found_app):
    
    def wsgi_app(environ, start_response):
        environ['matcha.matching'] = matching
        try:
            matched_case, matched_dict = matching(environ)
        except NotMatched:
            return not_found_app(environ, start_response)
        else:
            environ['matcha.matched_dict'] = matched_dict
            return matched_case(environ, start_response)
    return wsgi_app
945543
def serve(config):
    ""
    from gevent.pywsgi import WSGIServer

    app = make_app(config=config)

    host = app.config.get("HOST", '127.0.0.1')
    port = app.config.get("PORT", 5000)
    http_server = WSGIServer((host, port), app)
    http_server.serve_forever()
1067698
def start(self):
        
        logging.info("HTTP server: "
                     "Starting to listen for requests on '%s:%s'..." %
                     (self.conf['addr'], self.conf['port']))

        self.my_server = MyWSGIRefServer(host=self.conf['addr'],
                                         port=self.conf['port'],
                                         romana_http=self)

        self.http_thread = threading.Thread(
                    target = APP.run,
                    name   = "HTTP",
                    kwargs = {"quiet" : True, "server" : self.my_server})

        self.http_thread.daemon = True
        self.http_thread.start()
        time.sleep(1)
        if not self.wsgi_server_started:
            # Set the global flag indicating that everything should stop
            CURRENT_STATE._stop_all = True