예제 #1
0
파일: server.py 프로젝트: yaoshaojun/pyhp
    def run(self):
        # each new run needs a a new interpreter
        intrepreter = Interpreter()

        client, client_addr = self.wait_for_connection()
        request = self.read_request(client, 1024)

        bytecode = self._bytecode(request.filename)

        if bytecode is None:
            response = u"<html><body><p>404: File not found</p></body></html>"
            code = 404
        else:
            intrepreter.setup(request)
            response = intrepreter.run_return(bytecode)
            code = 200

        self.return_response(client, code, response)

        current_date = str(time.time())
        client_addr = '%s:%d' % (client_addr.get_host(),
                                 client_addr.get_port())
        print "[%s] %s [%d]: %s" % (current_date, client_addr, code,
                                    request.filename)

        self.connection_close(client)
예제 #2
0
 def run(self, code):
     bc = bytecode('/tmp/example.php', code)
     intrepreter = Interpreter()
     return intrepreter.run_return(bc)
예제 #3
0
파일: main.py 프로젝트: yaoshaojun/pyhp
def interpret(bc):
    """ Interpret bytecode and execute it
    """
    intrepreter = Interpreter()
    intrepreter.run(bc)
예제 #4
0
파일: main.py 프로젝트: blakev/pyhp
def interpret(bc):
    """ Interpret bytecode and execute it
    """
    intrepreter = Interpreter()
    intrepreter.run(bc)