File: serve-doc

package info (click to toggle)
ceph 18.2.7%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 1,186,140 kB
  • sloc: cpp: 6,278,388; ansic: 3,507,431; python: 372,964; asm: 216,381; java: 133,450; sh: 125,043; xml: 39,398; ruby: 32,026; makefile: 29,004; javascript: 23,994; cs: 18,980; perl: 9,708; sql: 7,833; lisp: 5,920; pascal: 3,109; ada: 1,681; yacc: 478; awk: 188; f90: 55; php: 1
file content (33 lines) | stat: -rwxr-xr-x 848 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/usr/bin/python3

from __future__ import print_function

import http.server
import socketserver
import os
import sys

path = os.path.dirname(sys.argv[0])
os.chdir(path)
os.chdir('..')
os.chdir('build-doc/output/html')

class ReusingTCPServer(http.server.SimpleHTTPRequestHandler):
    allow_reuse_address = True

    def send_head(self):
        # horrible kludge because SimpleHTTPServer is buggy wrt
        # slash-redirecting of requests with query arguments, and will
        # redirect to /foo?q=bar/ -- wrong slash placement
        self.path = self.path.split('?', 1)[0]
        return http.server.SimpleHTTPRequestHandler.send_head(self)

httpd = socketserver.TCPServer(
    ("", 8080),
    ReusingTCPServer,
    )
try:
    print("Serving doc at port: http://localhost:8080")
    httpd.serve_forever()
except KeyboardInterrupt:
    pass