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