MCPcopy Create free account
hub / github.com/datapane/datapane / wsgi

Method wsgi

python-client/src/datapane/_vendor/bottle.py:1088–1116  ·  view source on GitHub ↗

The bottle WSGI-interface.

(self, environ, start_response)

Source from the content-addressed store, hash-verified

1086 return new_iter
1087
1088 def wsgi(self, environ, start_response):
1089 """ The bottle WSGI-interface. """
1090 try:
1091 out = self._cast(self._handle(environ))
1092 # rfc2616 section 4.3
1093 if response._status_code in (100, 101, 204, 304)\
1094 or environ['REQUEST_METHOD'] == 'HEAD':
1095 if hasattr(out, 'close'): out.close()
1096 out = []
1097 exc_info = environ.get('bottle.exc_info')
1098 if exc_info is not None:
1099 del environ['bottle.exc_info']
1100 start_response(response._wsgi_status_line(), response.headerlist, exc_info)
1101 return out
1102 except (KeyboardInterrupt, SystemExit, MemoryError):
1103 raise
1104 except Exception as E:
1105 if not self.catchall: raise
1106 err = '<h1>Critical error while processing request: %s</h1>' \
1107 % html_escape(environ.get('PATH_INFO', '/'))
1108 if DEBUG:
1109 err += '<h2>Error:</h2>\n<pre>\n%s\n</pre>\n' \
1110 '<h2>Traceback:</h2>\n<pre>\n%s\n</pre>\n' \
1111 % (html_escape(repr(E)), html_escape(format_exc()))
1112 environ['wsgi.errors'].write(err)
1113 environ['wsgi.errors'].flush()
1114 headers = [('Content-Type', 'text/html; charset=UTF-8')]
1115 start_response('500 INTERNAL SERVER ERROR', headers, sys.exc_info())
1116 return [tob(err)]
1117
1118 def __call__(self, environ, start_response):
1119 """ Each instance of :class:'Bottle' is a WSGI application. """

Callers 1

__call__Method · 0.95

Calls 9

_castMethod · 0.95
_handleMethod · 0.95
html_escapeFunction · 0.85
tobFunction · 0.85
_wsgi_status_lineMethod · 0.80
flushMethod · 0.80
closeMethod · 0.45
getMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected