Reputation: 399
I need to store the output of a get function of a request handler before running the tornado server from outside the application.
Example:-
class Test(RequestHandler):
def get:
print "safds"'
....
...
I need to call get function without tornado loop server from outside. Is it possible ? Is there any turnaround. Please help.
Thanks
Upvotes: 1
Views: 821
Reputation: 1645
If you happen to end up reading this question, I knew that I had to somehow create an instance of my handler to be able to call the post
or get
function inside. After looking at the RequestHandler
's implementation, I came up with the following snippet:
from tornado.web import Application
from tornado.httpserver import HTTPRequest
mock_app = Mock(spec=Application)
request = HTTPRequest(
method='GET', uri='/', headers=None, body=None
)
response = Handler(mock_app, request).get()
Upvotes: 0