Reverse proxy python twisted

tags: python

Realize reverse proxy, imitate nginx

from twisted.internet import reactor
from twisted.web import proxy, server, static

root = static.File("./")

root.putChild('api', proxy.ReverseProxyResource('127.0.0.1', 9000, '/api'))
site = server.Site(root)

reactor.listenTCP(8081, site)
print "runing at 127.0.0.1:8081..."
reactor.run()

Related code:http://twistedmatrix.com/documents/current/web/examples/

Intelligent Recommendation

twisted

client side Server side...

Python twisted TCP communication script

-------------------server------------------- !/usr/bin/python coding=utf-8 from twisted.internet.protocol import Protocol from twisted.internet.protocol import Factory from twisted.internet.endpoints ...

Python twisted client server communication

Server -- coding:UTF-8 -- from time import ctime from twisted.internet import reactor from twisted.internet.protocol import Protocol, Factory PORT = 21567 class TSServProtocol(Protocol): def connectio...

Python twisted socket server client

2019 Unicorn Enterprise Heavy Gold Recruitment Python Engineer Standard >>> Use twisted to build a socket server, and can send messages to the client, relatively simple, directly on the code ...

More Recommendation

A simple p2p network in Python twisted

Let’s do a simple p2p network in Python. It should be able to discover other nodes and ping them over the network. We will be using twisted for building the network. I mostly used the&...

Recovery of twisted rectangles in Python pictures

In daily life, the handicapped parties often take some pictures crookedly, such as taking a certificate, test paper, PPT, etc. For example, the cover of the book below was originally a rectangle, but ...

On how to implement reverse proxy 1024 in Python

Now the implementation of the reverse proxy is mainly using Nginx, google version of the implementation of Python, most of them are implemented by Flask+requests. Too young. What should I do if I enco...

Pip installation prompts Twisted error (Python 3.6.4 installation Twisted error)

Pip installation prompts Twisted error (Python 3.6.4 installation Twisted error) When we had a Twisted error during the process of installing scrapy, when we continued to install Twisted, we continued...

Copyright  DMCA © 2018-2026 - All Rights Reserved - www.programmersought.com  User Notice

Top