-
Python에서 사용가능한 이벤트기반 네트워크 엔진
An event-driven networking engine
Web Server
from twisted.web import server, resource from twisted.internet import reactor, endpoints class Counter(resource.Resource): isLeaf = True numberRequests = 0 def render_GET(self, request): self.numberRequests += 1 request.setHeader(b"content-type", b"text/plain") content = u"I am request #{}\n".format(self.numberRequests) return content.encode("ascii") endpoints.serverFromString(reactor, "tcp:8080").listen(server.Site(Counter())) reactor.run()
Echo Server
from twisted.internet import protocol, reactor, endpoints class Echo(protocol.Protocol): def dataReceived(self, data): self.transport.write(data) class EchoFactory(protocol.Factory): def buildProtocol(self, addr): return Echo() endpoints.serverFromString(reactor, "tcp:1234").listen(EchoFactory()) reactor.run()
그외
Publish/Subscribe
Mail Client
SSH Client'Python' 카테고리의 다른 글
Python Numpy (0) 2022.12.13 Python Re - group (0) 2022.12.13 Python Re - match, search 예제 (0) 2022.12.13 Python, on Windows 7 (0) 2022.11.28 Flask Get Post Ex (0) 2022.08.08 Flask file upload(multipart) (0) 2022.07.31 Flask render_template (0) 2022.07.31 가변 파라미터 (0) 2022.07.23