Closed dferens closed 4 years ago
Good idea ! I take
it's in this repo !
Can you please post a little example for direct interaction with tornado? Thanks in advance.
Better ask @dferens ... It's just a "simple hack" (currently) ... which give the ability to interact with the tornado app instance (tornado.web.Application) in a self "app" property ... BTW, the "self.app" is (currently) only visible when it's running.
I don't have tried it yet ... but should work as is ... I imagine that you can add/remove routes to handlers ... or something like that
Sorry guys, but I'm not using this project anymore. After seeing this code I ended up writing my own project.
You're right ... it's awful ... (but it's true, currently, I don't understand why I must do that) But I promess you; i will work on this point in a future release ...
Keep in mind, that it's a personnal project ... and I've got a lot of private project that use it, as is ... Sure, it's not developped a pro fashion ;-) ... Currently, it's more empirical/pragmatic way ;-) But I will make effort ...
happy to see other project going in the same direction ! no trouble !
The only thing I need by tornado is to have the IP address of the connected client. I want to show that value in the webpage of the connected client.
PS: The place of the documentation "https://guy-docs.glitch.me/" is very often unavailable.
sadly, you can't get the exposed ip from the socket client ... (perhaps in future version) But with the http decorator, it's do'able, like this :
#!/usr/bin/python3 -u
# -*- coding: utf-8 -*-
import guy
class Server(guy.Guy):
"""<a href="/whatIsMyIp">test whatIsMyIp</a>"""
@guy.http("/whatIsMyIp")
def test(web):
ip = web.request.headers.get("X-Real-IP") or web.request.headers.get("X-Forwarded-For") or web.request.remote_ip
print(ip)
if __name__ == "__main__":
Server().serve()
Hi,
I simply added a reference to a tornado server instance so I'm able to customize it, like add handlers.
What do you think about it?