Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(378)

Side by Side Diff: blimp/tools/fake_web/server.py

Issue 2626423004: Remove all //blimp code. (Closed)
Patch Set: One last(?) `git merge` for good measure. Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « blimp/tools/fake_web/data/square.html ('k') | blimp/tools/generate-target-manifest.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #!/usr/bin/env python
2
3 # Copyright 2016 The Chromium Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file.
6
7 import argparse
8 import os
9 import subprocess
10 import sys
11 import tempfile
12
13 LIGHTTPD_CONF = """
14 server.document-root = "{root}"
15 server.port = {port}
16 mimetype.assign = (
17 ".html" => "text/html"
18 )
19 """
20
21 def run_lighttpd(conf):
22 """Run lighttpd in a subprocess and block until it exits.
23
24 Takes the lighttpd configuration file as a string.
25 """
26 with tempfile.NamedTemporaryFile() as conf_file:
27 conf_file.write(conf)
28 conf_file.file.close()
29 server = subprocess.Popen(['lighttpd', '-D', '-f', conf_file.name])
30 try:
31 server.wait()
32 except KeyboardInterrupt:
33 # Let lighttpd handle the signal.
34 server.wait()
35
36 def main():
37 script_dir = os.path.dirname(os.path.abspath(sys.argv[0]))
38 data_dir = os.path.join(script_dir, 'data')
39
40 parser = argparse.ArgumentParser()
41 parser.add_argument('-p', '--port', default=3000)
42 args = parser.parse_args()
43
44 conf = LIGHTTPD_CONF.format(port=args.port, root=data_dir)
45 print conf
46 run_lighttpd(conf)
47
48 if __name__ == '__main__':
49 main()
OLDNEW
« no previous file with comments | « blimp/tools/fake_web/data/square.html ('k') | blimp/tools/generate-target-manifest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698