You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

30 lines
882 B

#-*- coding: utf-8 -*-
from rivescript import RiveScript
from twisted.web import server, resource
from twisted.internet import reactor, endpoints
import HTMLParser
class Counter(resource.Resource):
isLeaf = True
# def render_GET(self, request):
# request.setHeader("content-type", "text/plain")
# print request
# return "hello\n"
def render_POST(self, request):
#print request.args["msg"]
message = u''.join(h.unescape(request.args["msg"]))
answer = rs.reply("localuser", message)
# unicodedata.normalize('NFKD', answer).encode('ascii','ignore')
return answer.encode('ascii', 'xmlcharrefreplace')
rs = RiveScript()
h = HTMLParser.HTMLParser()
endpoints.serverFromString(reactor, "tcp:1234").listen(server.Site(Counter()))