| OLD | NEW |
| 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 | 21 |
| 22 from sitescripts.web import multiplex | 22 from sitescripts.web import multiplex |
| 23 | 23 |
| 24 bindAddress = None | 24 bindAddress = os.environ.get('FCGI_BIND_ADDRESS') |
| 25 if 'FCGI_BIND_ADDRESS' in os.environ: | 25 if bindAddress: |
| 26 match = re.match(r'^(.*?):(\d+)$', os.environ['FCGI_BIND_ADDRESS']) | 26 match = re.match(r'^(.*?):(\d+)$', bindAddress) |
| 27 bindAddress = (match.group(1), int(match.group(2))) | 27 if match: |
| 28 bindAddress = (match.group(1), int(match.group(2))) |
| 29 |
| 28 srv = WSGIServer(multiplex, debug=False, bindAddress=bindAddress) | 30 srv = WSGIServer(multiplex, debug=False, bindAddress=bindAddress) |
| 29 | 31 |
| 30 if __name__ == '__main__': | 32 if __name__ == '__main__': |
| 31 srv.run() | 33 srv.run() |
| 32 | 34 |
| OLD | NEW |