def run(self):
        handlers = [
            (r'/app/(.*)', CorsStaticFileHandler, {"path": self.parameters.viewerPath}),
            (r'/init', InitHandler),
            (r'/data', DataHandler),
            (r'/sync', SyncHandler),
            (r'/rasters/(.*)', CorsStaticFileHandler, {"path": self.parameters.rastersPath}),
        ]

        if self.parameters.get_viewer_param()['hasRaster']:
            handlers.append((r'/tiles_info', TilesInfoHandler))
        if self.debug:
            handlers.append((r'/test/echo', EchoHandler))
            handlers.append((r'/test/ping', PingHandler))
        run(host="127.0.0.1", port=self.parameters.port, more_handlers=handlers)
    def run(self):
        handlers = [
            (r'/app/(.*)', CorsStaticFileHandler, {
                "path": self.parameters.viewerPath
            }),
            (r'/init', InitHandler),
            (r'/data', DataHandler),
            (r'/sync', SyncHandler),
            (r'/rasters/(.*)', CorsStaticFileHandler, {
                "path": self.parameters.rastersPath
            }),
        ]

        if self.parameters.get_viewer_param()['hasRaster']:
            handlers.append((r'/tiles_info', TilesInfoHandler))
        if self.debug:
            handlers.append((r'/test/echo', EchoHandler))
            handlers.append((r'/test/ping', PingHandler))
        run(host="127.0.0.1",
            port=self.parameters.port,
            more_handlers=handlers)
Beispiel #3
0
        return text


try:
    raise Exception("COMMENT_THIS_LINE_AND_LOG_TO_DAILY_FILE")
    from twisted.python.logfile import DailyLogFile
    logFile = DailyLogFile.fromFullPath("server.log")
    print("Logging to daily log file: server.log")
except Exception as e:
    import sys
    logFile = sys.stdout

run(
    host="127.0.0.1",
    port=8888,
    log=logFile,
    debug=True,
    static_path="./static",
    template_path="./template",
    locale_path="./locale",
    login_url="/auth/login",
    cookie_secret="32oETzKXQAGaYdkL5gEmGeJJFuYh7EQnp2XdTP1o/Vo=",
    base_handler=BaseHandler,
    db_handlers=cyclone.util.ObjectDict(
        #sqlite=cyclone.sqlite.InlineSQLite(":memory:"),
        redis=cyclone.redis.lazyConnectionPool(), ),
    more_handlers=[
        (r"/websocket", WebSocketHandler),
        (r"/xmlrpc", XmlrpcHandler),
    ])
Beispiel #4
0
#!/usr/bin/env python
# coding: utf-8
#
# Copyright 2010 Alexandre Fiori
# based on the original Tornado by Facebook
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.

import sys

import cyclone.sqlite
from cyclone.bottle import run, route

@route("/")
def index(web):
    web.write("Hello, world")

run(host="127.0.0.1", port=8888, log=sys.stdout)
Beispiel #5
0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.

import sys
import cyclone.sqlite
from cyclone.bottle import run, route


@route("/")
def index(web):
    web.write("try /sqlite\r\n")


@route("/sqlite")
def sqlite_get(web):
    v = web.settings.sqlite.runQuery("select strftime('%Y-%m-%d')")
    web.write("today is " + repr(v) + "\r\n")


run(
    host="127.0.0.1",
    port=8080,
    log=sys.stdout,  # or any file descriptor
    static_path="static",
    template_path="template",
    sqlite=cyclone.sqlite.InlineSQLite(":memory:"))
import sys
from cyclone.bottle import run, route


@route("/")
def index(web):
    web.write("Hello, world")

run(host="localhost", port=8888, log=sys.stdout)
Beispiel #7
0
                yield adjust(x), adjust(y), adjust(w), adjust(h)

    def mustashify(self, image):
        faces = 0
        for (x, y, w, h) in self.find_face(image):
            # resize our mustache keeping the aspect ratio
            mw, mh = self.im.size
            w = w-(w*10/100)
            ratio = mw/float(w)
            new_size = (w, int(float(mh)/ratio))
            new_mu = self.im.resize(new_size)

            # composite :}
            x = x+(x*5/100)
            y = (y+h)-new_size[1]-(h*15/100)
            image.paste(new_mu, (x, y, x+new_size[0], y+new_size[1]), new_mu)
            faces += 1

        return faces, image


def path_of(s):
    return os.path.join(os.path.dirname(os.path.abspath(__file__)), s)

run(host="127.0.0.1", port=int(os.getenv("PORT", 8888)),
    debug=False,
    template_path=path_of("./"),
    static_path=path_of("./static"),
    cache=Cache(path_of("./cache")),
    mumu=Mustashify(path_of("./static/mustache.png"), path_of("./haar.xml")))
Beispiel #8
0
    def xmlrpc_echo(self, text):
        return text


try:
    raise COMMENT_THIS_LINE_AND_LOG_TO_DAILY_FILE
    from twisted.python.logfile import DailyLogFile

    logFile = DailyLogFile.fromFullPath("server.log")
    print ("Logging to daily log file: server.log")
except Exception, e:
    import sys

    logFile = sys.stdout

run(
    host="127.0.0.1",
    port=8080,
    log=logFile,
    static_path="static",
    template_path="template",
    locale_path="locale",
    sqlite=cyclone.sqlite.InlineSQLite(":memory:"),
    redis=cyclone.redis.lazyRedisConnectionPool(),
    base_handler=BaseHandler,
    cookie_secret="32oETzKXQAGaYdkL5gEmGeJJFuYh7EQnp2XdTP1o/Vo=",
    login_url="/auth/login",
    more_handlers=[(r"/websocket", WebSocketHandler), (r"/xmlrpc", XmlrpcHandler)],
)
Beispiel #9
0
    def xmlrpc_echo(self, text):
        return text


try:
    raise Exception("COMMENT_THIS_LINE_AND_LOG_TO_DAILY_FILE")
    from twisted.python.logfile import DailyLogFile
    logFile = DailyLogFile.fromFullPath("server.log")
    print("Logging to daily log file: server.log")
except Exception as e:
    import sys
    logFile = sys.stdout

run(host="127.0.0.1", port=8888,
    log=logFile,
    debug=True,
    static_path="./static",
    template_path="./template",
    locale_path="./locale",
    login_url="/auth/login",
    cookie_secret="32oETzKXQAGaYdkL5gEmGeJJFuYh7EQnp2XdTP1o/Vo=",
    base_handler=BaseHandler,
    db_handlers=cyclone.util.ObjectDict(
        #sqlite=cyclone.sqlite.InlineSQLite(":memory:"),
        redis=cyclone.redis.lazyConnectionPool(),
    ),
    more_handlers=[
        (r"/websocket", WebSocketHandler),
        (r"/xmlrpc",    XmlrpcHandler),
    ])
import sys
from cyclone.bottle import run, route


@route("/")
def index(web):
    web.write("Hello, world")


run(host="localhost", port=8888, log=sys.stdout)
Beispiel #11
0
    allowNone = True

    def xmlrpc_echo(self, text):
        return text


try:
    raise COMMENT_THIS_LINE_AND_LOG_TO_DAILY_FILE
    from twisted.python.logfile import DailyLogFile
    logFile = DailyLogFile.fromFullPath("server.log")
    print("Logging to daily log file: server.log")
except Exception, e:
    import sys
    logFile = sys.stdout

run(host="127.0.0.1",
    port=8080,
    log=logFile,
    static_path="static",
    template_path="template",
    locale_path="locale",
    sqlite=cyclone.sqlite.InlineSQLite(":memory:"),
    redis=cyclone.redis.lazyRedisConnectionPool(),
    base_handler=BaseHandler,
    cookie_secret="32oETzKXQAGaYdkL5gEmGeJJFuYh7EQnp2XdTP1o/Vo=",
    login_url="/auth/login",
    more_handlers=[
        (r"/websocket", WebSocketHandler),
        (r"/xmlrpc", XmlrpcHandler),
    ])
Beispiel #12
0
                                     self.haar_scale, self.min_neighbors,
                                     self.haar_flags, self.min_size)
        #t = cv.GetTickCount() - t
        adjust = lambda v: v*self.image_scale
        if faces:
            for ((x, y, w, h), n) in faces:
                yield adjust(x), adjust(y), adjust(w), adjust(h)

    def mustashify(self, image):
        for (x, y, w, h) in self.find_face(image):
            # resize our mustache keeping the aspect ratio
            mw, mh = self.im.size
            w = w-(w*10/100)
            ratio = mw/float(w)
            new_size = (w, int(float(mh)/ratio))
            new_mu = self.im.resize(new_size)

            # composite :}
            x = x+(x*5/100)
            y = (y+h)-new_size[1]-(h*15/100)
            image.paste(new_mu, (x, y, x+new_size[0], y+new_size[1]), new_mu)

        return image


run(host="127.0.0.1", port=8888,
    debug=True,
    template_path=path_of("./"),
    static_path=path_of("./static"),
    mumu=Mustashify(path_of("./static/mustache.png"), path_of("./haar.xml")))
Beispiel #13
0
#!/usr/bin/env python
# coding: utf-8
#
# Copyright 2010 Alexandre Fiori
# based on the original Tornado by Facebook
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.

import sys

from cyclone.bottle import run, route


@route("/")
def index(web):
    web.write("Hello, world")


run(host="127.0.0.1", port=8888, log=sys.stdout)
Beispiel #14
0
        faces = 0
        for (x, y, w, h) in self.find_face(image):
            # resize our mustache keeping the aspect ratio
            mw, mh = self.im.size
            w = w - (w * 10 / 100)
            ratio = mw / float(w)
            new_size = (w, int(float(mh) / ratio))
            new_mu = self.im.resize(new_size)

            # composite :}
            x = x + (x * 5 / 100)
            y = (y + h) - new_size[1] - (h * 15 / 100)
            image.paste(new_mu, (x, y, x + new_size[0], y + new_size[1]),
                        new_mu)
            faces += 1

        return faces, image


def path_of(s):
    return os.path.join(os.path.dirname(os.path.abspath(__file__)), s)


run(host="127.0.0.1",
    port=int(os.getenv("PORT", 8888)),
    debug=False,
    template_path=path_of("./"),
    static_path=path_of("./static"),
    cache=Cache(path_of("./cache")),
    mumu=Mustashify(path_of("./static/mustache.png"), path_of("./haar.xml")))
Beispiel #15
0
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.

import sys
import cyclone.sqlite
from cyclone.bottle import run, route

@route("/")
def index(web):
    web.write("try /sqlite\r\n")

@route("/sqlite")
def sqlite_get(web):
    v = web.settings.sqlite.runQuery("select strftime('%Y-%m-%d')")
    web.write("today is " + repr(v) + "\r\n")

run(host="127.0.0.1", port=8080,
    log=sys.stdout, # or any file descriptor
    static_path="static", template_path="template",
    sqlite=cyclone.sqlite.InlineSQLite(":memory:"))