コード例 #1
0
ファイル: server.py プロジェクト: ardcore/cocos2d-javascript
 def __init__(self, *args):
     global CODE_URL, CONFIG_FILE
     self.compiler = Compiler(CONFIG_FILE)
     if not CODE_URL:
         CODE_URL = re.sub('^/?public', '', self.compiler.output)
     print "Serving as:", CODE_URL
     SimpleHTTPServer.SimpleHTTPRequestHandler.__init__(self, *args)
コード例 #2
0
ファイル: server.py プロジェクト: ardcore/cocos2d-javascript
class Cocos2D(SimpleHTTPServer.SimpleHTTPRequestHandler):

    def __init__(self, *args):
        global CODE_URL, CONFIG_FILE
        self.compiler = Compiler(CONFIG_FILE)
        if not CODE_URL:
            CODE_URL = re.sub('^/?public', '', self.compiler.output)
        print "Serving as:", CODE_URL
        SimpleHTTPServer.SimpleHTTPRequestHandler.__init__(self, *args)


    def do_GET(self):
        self.path = self.path.split('?')[0] # Strip off params
        if self.path == '/':
            self.path = '/public/index.html'
            return SimpleHTTPServer.SimpleHTTPRequestHandler.do_GET(self)
        else:
            if CODE_URL == self.path:
                print "Building code"
                code = self.compiler.make()

                self.send_response(200)
                self.send_header('Content-Type', 'text/javascript')
                self.end_headers()
                self.wfile.write(code.encode('utf-8'))

            else:
                self.path = '/public' + os.path.normpath(self.path)
                return SimpleHTTPServer.SimpleHTTPRequestHandler.do_GET(self)