コード例 #1
0
ファイル: __init__.py プロジェクト: diunko/worker-dummy
# coding: utf-8

# just to render sha1 different

from cocaine.context import Dispatch, Log

from cocaine.http import http
from cocaine.timers import timer
from cocaine.fs import fs

from hashlib import sha512

log = Log()
dispatch = Dispatch()


@http
def hash_headers(request, response):
    def process():
        result = "<html><head>Hash</head>%s</html>\r\n" % sha512(str(request.headers)).hexdigest()

        response.writeHead(200, {"Content-Type": "text/plain"})

        response.write(result)
        response.close()

    request.on("request", process)


def reverse_echo(request, response):
    def process(chunk):
コード例 #2
0
ファイル: __init__.py プロジェクト: 3Hren/cocaine-plugins
# coding: utf-8

from cocaine.context import Log, Dispatch
from cocaine.http import http

from hashlib import sha512

log = Log()
dispatch = Dispatch()

@http
def hash_headers(request, response):
    def process():
        result = "<html><head>Hash</head>%s</html>\r\n" % sha512(str(request.headers)).hexdigest()
        
        response.writeHead(200, {
            'Content-Type': 'text/plain'
        })
        
        response.write(result)
        response.close()

    request.on("request", process)

dispatch.on("hash", hash_headers)
コード例 #3
0
ファイル: __init__.py プロジェクト: tinybit/cocs10test
# coding: utf-8

from cocaine.context import Dispatch, Log
import datetime

log = Log()
dispatch = Dispatch()

def time_echo(request, response):
    def process(chunk):
        response.write(chunk + " " + str(datetime.datetime.now()))

    request.on("chunk", process)

dispatch.on("echo", time_echo)
# coding: utf-8

from cocaine.context import Log, Dispatch
from cocaine.http import http

from hashlib import sha512

log = Log()
dispatch = Dispatch()


@http
def hash_headers(request, response):
    def process():
        result = "<html><head>Hash</head>%s</html>\r\n" % sha512(
            str(request.headers)).hexdigest()

        response.writeHead(200, {'Content-Type': 'text/plain'})

        response.write(result)
        response.close()

    request.on("request", process)


dispatch.on("hash", hash_headers)