Ejemplo n.º 1
0
def main():
    import sys
    if 2 < sys.version_info[0]:
        import os
        import http.server as hs

        handler_class = hs.partial(hs.SimpleHTTPRequestHandler,
                                   directory=os.getcwd())
        hs.test(HandlerClass=handler_class, port=8000, bind='')
    else:
        from SimpleHTTPServer import test
        test()
#! /usr/bin/env python

from SimpleHTTPServer import SimpleHTTPRequestHandler, test


class CORSHTTPRequestHandler(SimpleHTTPRequestHandler):
    def end_headers(self):
        self.send_header('Access-Control-Allow-Origin', '*')
        super(CORSHTTPRequestHandler, self).end_headers(self)


if __name__ == '__main__':
    test(HandlerClass=CORSHTTPRequestHandler)
Ejemplo n.º 3
0
#!/usr/bin/env python
import urllib

from SimpleHTTPServer import SimpleHTTPRequestHandler, test

PROVIDER_URL = 'http://localhost:8080' 

class ProxyingHTTPHandler(SimpleHTTPRequestHandler):

    def do_GET(self):
        if self.path.startswith('/openplanetideas-plusyou'):
            self.copyfile(urllib.urlopen(PROVIDER_URL + self.path), self.wfile)
        else:
            return SimpleHTTPRequestHandler.do_GET(self)

if __name__ == '__main__':
    test(ProxyingHTTPHandler)
Ejemplo n.º 4
0
#!/usr/bin/env python
import urllib

from SimpleHTTPServer import SimpleHTTPRequestHandler, test

PROVIDER_URL = 'http://localhost:8080'


class ProxyingHTTPHandler(SimpleHTTPRequestHandler):
    def do_GET(self):
        if self.path.startswith('/openplanetideas-plusyou'):
            self.copyfile(urllib.urlopen(PROVIDER_URL + self.path), self.wfile)
        else:
            return SimpleHTTPRequestHandler.do_GET(self)


if __name__ == '__main__':
    test(ProxyingHTTPHandler)
Ejemplo n.º 5
0
function set_layers() {
   wwt.setBackgroundImageByName('Wise All Sky (Infrared)');
   wwt.setForegroundImageByName('Toasty map');
   wwt.setForegroundOpacity(50);
}
</script>

<div id="WWTCanvas" style="width: 750px; height: 750px; border-style: none; border-width: 0px;">
</div>
<div id="UI">

<select id="select-foreground">
<option value="Digitized Sky Survey (Color)"> Optical </option>
<option value="WMAP ILC 5-Year Cosmic Microwave Background"> WMAP 5-Year </option>
<option value="SFD Dust Map (Infrared)"> SFD </option>
<option value="IRIS: Improved Reprocessing of IRAS Survey (Infrared)"> IRIS </option>
<option value="Hydrogen Alpha Full Sky Map"> H-alpha </option>
</select>

<input id='opacity' type="range" name="opacity" min="10" max="100">

</div>
</body>
</html>
"""

if __name__ == "__main__":
    sys.argv.insert(1, '8000')
    test(HandlerClass=SimpleWWTHandler)
Ejemplo n.º 6
0
            self.path = "/all"
            return self.send_head()

        self.send_error(404, "Invalid path")
        return None

    def donepage(self, title, data):
        f = cStringIO.StringIO(self.htmlpage(title, data))
        self.send_response(200)
        self.send_header("Content-type", "text/html")
        self.end_headers()
        return f


if __name__ == '__main__':
    if len(sys.argv) <= 1:
        print "Usage: python httpxam.py <directory>"
        print "  psyco.dump and any .py files containing code objects"
        print "  are loaded from the <directory>."
        sys.exit(1)
    DIRECTORY = sys.argv[1]
    del sys.argv[1]
    filename = os.path.join(DIRECTORY, 'psyco.dump')
    if not os.path.isfile(filename) and os.path.isfile(DIRECTORY):
        filename = DIRECTORY
        DIRECTORY = os.path.dirname(DIRECTORY)
    tracefilename = os.path.join(DIRECTORY, 'psyco.trace')
    codebufs = xam.readdump(filename)
    FILENAME = filename  # CT hack
    test(CodeBufHTTPHandler)
Ejemplo n.º 7
0
                return None
            for index in str(argv[2]), "index.html":
                index = os.path.join(path, index)
                if os.path.exists(index):
                    path = index
                    break
            else:
                return self.list_directory(path)
        ctype = self.guess_type(path)
        try:
            f = open(path, 'rb')
        except IOError:
            self.send_error(404, "File not found")
            return None
        try:
            self.send_response(200)
            self.send_header("Content-type", ctype)
            fs = os.fstat(f.fileno())
            self.send_header("Content-Length", str(fs[6]))
            self.send_header("Last-Modified",
                             self.date_time_string(fs.st_mtime))
            self.end_headers()
            return f
        except:
            f.close()
            raise


test(HandlerClass=ComplexHTTPRequestHandler,
     ServerClass=BaseHTTPServer.HTTPServer,
     filename=argv[2])
Ejemplo n.º 8
0
def serve(path):
    os.chdir(path)
    test()
Ejemplo n.º 9
0
            self.path = "/all"
            return self.send_head()
        
        self.send_error(404, "Invalid path")
        return None

    def donepage(self, title, data):
        f = cStringIO.StringIO(self.htmlpage(title, data))
        self.send_response(200)
        self.send_header("Content-type", "text/html")
        self.end_headers()
        return f


if __name__ == '__main__':
    if len(sys.argv) <= 1:
        print "Usage: python httpxam.py <directory>"
        print "  psyco.dump and any .py files containing code objects"
        print "  are loaded from the <directory>."
        sys.exit(1)
    DIRECTORY = sys.argv[1]
    del sys.argv[1]
    filename = os.path.join(DIRECTORY, 'psyco.dump')
    if not os.path.isfile(filename) and os.path.isfile(DIRECTORY):
        filename = DIRECTORY
        DIRECTORY = os.path.dirname(DIRECTORY)
    tracefilename = os.path.join(DIRECTORY, 'psyco.trace')
    codebufs = xam.readdump(filename)
    FILENAME = filename # CT hack
    test(CodeBufHTTPHandler)
Ejemplo n.º 10
0
import os, time
from subprocess import call
from SimpleHTTPServer import test

if __name__ == "__main__":
    result = os.fork()
    if result:
        time.sleep(0.5)
        print "This the pid of the child process: %s. Now I am in the parent."\
              % result
        call(["konqueror", "http://localhost:8000"])
    else:
        print "I am in the child process."
        test()
        

        
Ejemplo n.º 11
0
# use python http.server to serve local presentation
# call this script from the talk root directory

# You can also run manually from command line
#
# python2 -m SimpleHTTPServer 8000
# python3 -m http.server 8000

import sys

try:
    port = int(sys.argv[1])
except:
    port = 8000

try:
    # Python 2
    from SimpleHTTPServer import test, SimpleHTTPRequestHandler
except ImportError:
    # Python 3
    from http.server import test, SimpleHTTPRequestHandler

test(SimpleHTTPRequestHandler)
Ejemplo n.º 12
0
def serve(path):
    os.chdir(path)
    test()
        self.__state__['request_no'] = req_no

        req_date = datetime.datetime.now().strftime("%c")
        client_detail = "%s:%s" % (self.client_address[0],
                                   str(self.client_address[1]))

        f.write('<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">')
        f.write("<html>\n<body>\n<pre>")
        f.write("Request No: %s\n" % req_no)
        f.write("Client details: %s\n" % client_detail)
        f.write("Date: %s\n\n" % req_date)
        f.write("<hr>Previous requests:\n%s" %
                "\n".join(self.__request_list__))
        f.write("</pr>\n<hr>\n</body>\n</html>\n")
        length = f.tell()
        f.seek(0)

        self.send_response(200)
        encoding = sys.getfilesystemencoding()
        self.send_header("Content-type", "text/html; charset=%s" % encoding)
        self.send_header("Content-Length", str(length))
        self.end_headers()
        self.__request_list__.append("Req No: %s: Client:%s Date: %s" %
                                     (req_no, client_detail, req_date))
        return f


if __name__ == '__main__':
    test(HandlerClass=MyHTTPHandler)
Ejemplo n.º 14
0
from SimpleHTTPServer import SimpleHTTPRequestHandler, test
import os

class MyHandler(SimpleHTTPRequestHandler):
    def __init__(self, *args, **kwargs):
        SimpleHTTPRequestHandler.__init__(self, *args, **kwargs)
        self.extensions_map[''] = 'text/html'

    def send_head(self):
        prefix = os.environ.get('BASEURL', '')
        if prefix:
            if self.path.startswith(prefix):
                self.path = self.path[len(prefix):]
        fpath = self.translate_path(self.path)
        if os.path.isdir(fpath):
            default = os.environ.get('DEFAULT_DOCUMENT', 'contents')
            for index in default, default + ".html":
                if os.path.exists(os.path.join(fpath, index)):
                    self.path = '/'.join([self.path, index])
                    break
        return SimpleHTTPRequestHandler.send_head(self)

if __name__=='__main__':
    import os
    os.chdir(os.environ.get('DST', 'build'))
    test(HandlerClass=MyHandler)
Ejemplo n.º 15
0
function set_layers() {
   wwt.setBackgroundImageByName('Wise All Sky (Infrared)');
   wwt.setForegroundImageByName('Toasty map');
   wwt.setForegroundOpacity(50);
}
</script>

<div id="WWTCanvas" style="width: 750px; height: 750px; border-style: none; border-width: 0px;">
</div>
<div id="UI">

<select id="select-foreground">
<option value="Digitized Sky Survey (Color)"> Optical </option>
<option value="WMAP ILC 5-Year Cosmic Microwave Background"> WMAP 5-Year </option>
<option value="SFD Dust Map (Infrared)"> SFD </option>
<option value="IRIS: Improved Reprocessing of IRAS Survey (Infrared)"> IRIS </option>
<option value="Hydrogen Alpha Full Sky Map"> H-alpha </option>
</select>

<input id='opacity' type="range" name="opacity" min="10" max="100">

</div>
</body>
</html>
"""

if __name__ == "__main__":
    sys.argv.insert(1, '8000')
    test(HandlerClass=SimpleWWTHandler)
Ejemplo n.º 16
0
from SimpleHTTPServer import SimpleHTTPRequestHandler, test
import os


class MyHandler(SimpleHTTPRequestHandler):
    def __init__(self, *args, **kwargs):
        SimpleHTTPRequestHandler.__init__(self, *args, **kwargs)
        self.extensions_map[''] = 'text/html'

    def send_head(self):
        prefix = os.environ.get('BASEURL', '')
        if prefix:
            if self.path.startswith(prefix):
                self.path = self.path[len(prefix):]
        fpath = self.translate_path(self.path)
        if os.path.isdir(fpath):
            default = os.environ.get('DEFAULT_DOCUMENT', 'contents')
            for index in default, default + ".html":
                if os.path.exists(os.path.join(fpath, index)):
                    self.path = '/'.join([self.path, index])
                    break
        return SimpleHTTPRequestHandler.send_head(self)


if __name__ == '__main__':
    import os
    os.chdir(os.environ.get('DST', 'build'))
    test(HandlerClass=MyHandler)