MCPcopy Index your code
hub / github.com/fluentpython/example-code-2e / wsgi

Method wsgi

21-async/mojifinder/bottle.py:957–981  ·  view source on GitHub ↗

The bottle WSGI-interface.

(self, environ, start_response)

Source from the content-addressed store, hash-verified

955 return new_iter
956
957 def wsgi(self, environ, start_response):
958 """ The bottle WSGI-interface. """
959 try:
960 out = self._cast(self._handle(environ))
961 # rfc2616 section 4.3
962 if response._status_code in (100, 101, 204, 304)\
963 or environ['REQUEST_METHOD'] == 'HEAD':
964 if hasattr(out, 'close'): out.close()
965 out = []
966 start_response(response._status_line, response.headerlist)
967 return out
968 except (KeyboardInterrupt, SystemExit, MemoryError):
969 raise
970 except Exception:
971 if not self.catchall: raise
972 err = '<h1>Critical error while processing request: %s</h1>' \
973 % html_escape(environ.get('PATH_INFO', '/'))
974 if DEBUG:
975 err += '<h2>Error:</h2>\n<pre>\n%s\n</pre>\n' \
976 '<h2>Traceback:</h2>\n<pre>\n%s\n</pre>\n' \
977 % (html_escape(repr(_e())), html_escape(format_exc()))
978 environ['wsgi.errors'].write(err)
979 headers = [('Content-Type', 'text/html; charset=UTF-8')]
980 start_response('500 INTERNAL SERVER ERROR', headers, sys.exc_info())
981 return [tob(err)]
982
983 def __call__(self, environ, start_response):
984 ''' Each instance of :class:'Bottle' is a WSGI application. '''

Callers 1

__call__Method · 0.95

Calls 7

_castMethod · 0.95
_handleMethod · 0.95
html_escapeFunction · 0.85
_eFunction · 0.85
tobFunction · 0.85
closeMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected