socketify.py/examples/proxy.py

19 wiersze
449 B
Python
Czysty Zwykły widok Historia

2022-11-08 10:44:16 +00:00
from socketify import App
2022-11-16 19:28:46 +00:00
2022-11-08 10:44:16 +00:00
def home(res, req):
2022-11-16 19:28:46 +00:00
res.write("<html><h1>")
res.write("Your proxied IP is: %s" % res.get_proxied_remote_address())
res.write("</h1><h1>")
res.write("Your IP as seen by the origin server is: %s" % res.get_remote_address())
res.end("</h1></html>")
2022-11-08 10:44:16 +00:00
app = App()
app.get("/*", home)
2022-11-16 19:28:46 +00:00
app.listen(
3000,
lambda config: print("Listening on port http://localhost:%d now\n" % config.port),
)
app.run()