Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: multiplexer.fcgi

Issue 6209629180657664: Issue 2169 - Unify development and production implementation of multiplexer (Closed)
Patch Set: Created March 23, 2015, 4:23 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | multiplexer.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # coding: utf-8 2 # coding: utf-8
3 3
4 # This file is part of the Adblock Plus web scripts, 4 # This file is part of the Adblock Plus web scripts,
5 # Copyright (C) 2006-2015 Eyeo GmbH 5 # Copyright (C) 2006-2015 Eyeo GmbH
6 # 6 #
7 # Adblock Plus is free software: you can redistribute it and/or modify 7 # Adblock Plus is free software: you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License version 3 as 8 # it under the terms of the GNU General Public License version 3 as
9 # published by the Free Software Foundation. 9 # published by the Free Software Foundation.
10 # 10 #
11 # Adblock Plus is distributed in the hope that it will be useful, 11 # Adblock Plus is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details. 14 # GNU General Public License for more details.
15 # 15 #
16 # You should have received a copy of the GNU General Public License 16 # You should have received a copy of the GNU General Public License
17 # along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. 17 # along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
18 18
19 import os, re 19 import os, re
20 from flup.server.fcgi import WSGIServer 20 from flup.server.fcgi import WSGIServer
21 from urlparse import urlparse
22 21
23 from sitescripts.web import handlers 22 from sitescripts.web import multiplex
24
25 class MultiplexerApp:
26 def __call__(self, environ, start_response):
27 if 'REQUEST_URI' in environ:
28 request = urlparse(environ['REQUEST_URI'])
29 if request.path in handlers:
30 return handlers[request.path](environ, start_response)
31
32 request_dir = re.sub(r'[^/]+$', '', request.path)
33 if request_dir in handlers:
34 return handlers[request_dir](environ, start_response)
35
36 start_response('404 Not Found', [('Content-Type', 'text/html')])
37 return ["Not Found"]
38 23
39 bindAddress = None 24 bindAddress = None
40 if 'FCGI_BIND_ADDRESS' in os.environ: 25 if 'FCGI_BIND_ADDRESS' in os.environ:
41 match = re.match(r'^(.*?):(\d+)$', os.environ['FCGI_BIND_ADDRESS']) 26 match = re.match(r'^(.*?):(\d+)$', os.environ['FCGI_BIND_ADDRESS'])
42 bindAddress = (match.group(1), int(match.group(2))) 27 bindAddress = (match.group(1), int(match.group(2)))
43 srv = WSGIServer(MultiplexerApp(), debug=False, bindAddress=bindAddress) 28 srv = WSGIServer(multiplex, debug=False, bindAddress=bindAddress)
44 29
45 if __name__ == '__main__': 30 if __name__ == '__main__':
46 srv.run() 31 srv.run()
47 32
OLDNEW
« no previous file with comments | « no previous file | multiplexer.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld