コード例 #1
0
ファイル: server.py プロジェクト: DABodr/PadTool
def launchWebServer(cfg, port, user, pwd):
    host = '0.0.0.0'
    while True:
        server = CustomHTTPServer(('0.0.0.0', int(port)))
        server.set_auth(user, pwd)
        server.setCfg(cfg)
        server.serve_forever()
コード例 #2
0
            response = {'success': False, 'error': 'Invalid credentials'}

        self.wfile.write(bytes(json.dumps(response), 'utf-8'))


class CustomHTTPServer(http.server.HTTPServer):
    key = ''

    def __init__(self, address, handlerClass=CustomServerHandler):
        super().__init__(address, handlerClass)

    def set_auth(self, username, password):
        self.key = base64.b64encode(
            bytes('%s:%s' % (username, password), 'utf-8')).decode('ascii')

    def get_auth_key(self):
        return self.key


print('Saftblandaren started at {}'.format(datetime.now()))
server = CustomHTTPServer(('', PORT))
server.set_auth(USER, PASSWORD)
try:
    server.serve_forever()
except Exception as e:
    print(e)
    pass
blender.cleanup()
server.server_close()
print('Saftblandaren exited at {}'.format(datetime.now()))
コード例 #3
0
ファイル: SSL.py プロジェクト: habiibaz/SSL
        return getvars


class CustomHTTPServer(http.server.HTTPServer):
    key = ''

    def __init__(self, address, handlerClass=CustomServerHandler):
        super().__init__(address, handlerClass)

    def set_auth(self, username, password):
        self.key = base64.b64encode(
            bytes('%s:%s' % (username, password), 'utf-8')).decode('ascii')

    def get_auth_key(self):
        return self.key


if __name__ == '__main__':
    PORT = 1404
    USERNAME = '******'
    PASSWORD = '******'
    server = CustomHTTPServer(('localhost', PORT))
    server.socket = ssl.wrap_socket(server.socket,
                                    keyfile='Private.pem',
                                    certfile='Public.pem',
                                    server_side=True)
    server.set_auth(USERNAME, PASSWORD)
    print('Serving at', PORT)
    server.serve_forever()
コード例 #4
0
ファイル: demo.py プロジェクト: y0zg/awspython
                                    keep_blank_values=1)
        else:
            postvars = {}

        return postvars

    def _parse_GET(self):
        getvars = parse_qs(urlparse(self.path).query)

        return getvars


class CustomHTTPServer(http.server.HTTPServer):
    key = ''

    def __init__(self, address, handlerClass=CustomServerHandler):
        super().__init__(address, handlerClass)

    def set_auth(self, username, password):
        self.key = base64.b64encode(
            bytes('%s:%s' % (username, password), 'utf-8')).decode('ascii')

    def get_auth_key(self):
        return self.key


if __name__ == '__main__':
    server = CustomHTTPServer(('', 8888))
    server.set_auth('demo', 'demo')
    server.serve_forever()
コード例 #5
0
    def __init__(self, address, handlerClass=CustomServerHandler):
        super().__init__(address, handlerClass)

    def set_auth(self, username, password):
        self.key = base64.b64encode(
            bytes('%s:%s' % (username, password), 'utf-8')).decode('ascii')

    def get_auth_key(self):
        return self.key


if __name__ == '__main__':
    if ( SSL == "true" ):
        import ssl
        server = CustomHTTPServer(('', PORT))
        server.set_auth(USERNAME, USERPASS)
        server.socket = ssl.wrap_socket (server.socket,
        keyfile="/etc/ssl/private/ssl-cert-snakeoil.key", 
        certfile='/etc/ssl/certs/ssl-cert-snakeoil.pem', server_side=True)
        server.serve_forever()
    else:
        server = CustomHTTPServer( ('', PORT))
        server.set_auth(USERNAME, USERPASS)
        server.serve_forever()

    import time
    import systemd.daemon

    print('Starting up ...')
    time.sleep(10)
    print('Startup complete')
コード例 #6
0
class CustomHTTPServer(http.server.HTTPServer):
    key = ''

    def __init__(self, address, handlerClass=CustomServerHandler):
        super().__init__(address, handlerClass)

    def set_auth(self, username, password):
        self.key = base64.b64encode(
            bytes('%s:%s' % (username, password), 'utf-8')).decode('ascii')

    def get_auth_key(self):
        return self.key


if __name__ == '__main__':
    with picamera.PiCamera() as camera:
        camera.resolution = (resolutionV, resolutonH)
        camera.framerate = framerate
        output = StreamingOutput()
        camera.start_recording(output, format='mjpeg')
        camera.start_recording(get_data() + '.h264',
                               splitter_port=2,
                               resize=(1920, 1080))
        try:
            server = CustomHTTPServer(('', 8080))
            server.set_auth(camera_name, camera_psswd)
            server.serve_forever()
        finally:
            camera.stop_recording(splitter_port=2)
            camera.stop_recording()
コード例 #7
0
ファイル: httpsrv.py プロジェクト: eu21/test
                self.rfile.read(length), keep_blank_values=1)
        else:
            postvars = {}

        return postvars

    def _parse_GET(self):
        getvars = parse_qs(urlparse(self.path).query)

        return getvars


class CustomHTTPServer(http.server.HTTPServer):
    key = ''

    def __init__(self, address, handlerClass=CustomServerHandler):
        super().__init__(address, handlerClass)

    def set_auth(self, username, password):
        self.key = base64.b64encode(
            bytes('%s:%s' % (username, password), 'utf-8')).decode('ascii')

    def get_auth_key(self):
        return self.key


if __name__ == '__main__':
    server = CustomHTTPServer(('', 80))
    server.set_auth('admin', '1234')
    server.serve_forever()
コード例 #8
0
                        default='demo')
    parser.add_argument("pw",
                        help="server password",
                        nargs='?',
                        default='demo')
    parser.add_argument("-P",
                        "--post",
                        help="enable POST requests (WARNING: DANGEROUS)",
                        action="store_true")
    parser.add_argument(
        "--cmd", help="bash command to be run before refreshing index.html")

    args = parser.parse_args()

    # store and print parsed arguments
    print('Information from arguments...')
    print('...server IP: ' + args.ip)
    print('...server port: ' + args.port)
    print('...server user: '******'...server password: '******'...POST requests are {}'.format(
        'ENABLED' if args.post else 'DISABLED'))
    if args.cmd:
        print('...command to be run before index refresh: ' + args.cmd)
    print('\n')

    server = CustomHTTPServer((args.ip, int(args.port)),
                              post_enabled=True if args.post else False)
    server.set_auth(args.user, args.pw)
    server.serve_forever()