I've seen very little information online for creating a web server with Tornado to handle GET/POST requests from an android phone. I'm relatively new to both Android and web server dev but I have some experience with Tornado so I thought I would use that, although there seems to be a huge lack of tutorials for using these two technologies.
import tornado.ioloop
import tornado.web
class MainHandler(tornado.web.RequestHandler):
def get(self):
self.write("Hello, world")
def main():
return tornado.web.Application([
(r"/", MainHandler),
])
if __name__ == "__main__":
app = main()
app.listen(8888)
tornado.ioloop.IOLoop.current().start()
I'm using the HttpURLConnection class to create a connection with the web server, which has worked with a tutorial I used, but I'm now trying to connect my android app to my Tornado web server on my computer to simply get "Hello world" from the server when I click a button on my android app. Instead of providing the tutorial's http.php/get URL (which is tested and works), I want to try to use my computer's IP to connect with my server, so I replaced the URL with http://x.x.x.x:8888/, my IPv4 address, but that doesn't work.
GetBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View V) {
new MakeNetworkCall().execute("http://androidpala.com/" +
"tutorial/http.php?get=1", "Get");
}
});
I can provide more of my android code if necessary. Thanks for the help, I can't figure this out at all.