How to write a web server using twisted?

How to write a simple HTTP server using a twisted structure?

I want the web server to be able to receive an HTTP request and return a response to the client.

I look at the twisted documentation and get a little confused (maybe just lazy), but it is not very clear how to do this, especially how the twist server receives the request parameters?

This is my effort ...

from twisted.web import proxy, http from twisted.internet import reactor from twisted.python import log from twisted.protocols import basic import sys log.startLogging(sys.stdout) class InformixProtocol(basic.LineReceiver): def lineReceived(self, user): self.transport.write("Hello this is twisted web server!") self.transport.loseConnection() class ProxyFactory(http.HTTPFactory): #protocol = proxy.Proxy protocol = InformixProtocol reactor.listenTCP(8080, ProxyFactory()) reactor.run() 

thanks

Gough

+4
source share
1 answer

Source: https://habr.com/ru/post/1346234/


All Articles