Response 404 attempting API

Viewed 30

I get response 404 when I attempt to access the facebook API with the Tornado library. The objective was to see the results on my localhost however It is not sending the request properly.

I assume an additional parameter such as body is allowed because AsyncHTTPClient also takes HTTPrequest as its argument.

Here is what I have tried:

import os
import json

import tornado.httpclient
import tornado.ioloop
import tornado.options
import tornado.web
import tornado.httpserver

import logging

logger = logging.getLogger(__name__)

from tornado.options import define, options
define("port", default=8070, help="run on the given port", type=int)

location = os.path.join(os.path.dirname(__file__), 'config.json')

config_file = open(location)
config = json.load(config_file)
config_file.close()

class testClient(tornado.web.RequestHandler):
    async def get(self):
        client = tornado.httpclient.AsyncHTTPClient()
        try:
            await client.fetch('https://graph.facebook.com/oauth/access_token', body = config, callback = self._response)
        except:
            logging.error("exception in asynchronous operation",exc_info=True)

    def _response(self, response):
        result = response.json()
        return result
    
if __name__ == "__main__":
    tornado.options.parse_command_line()
    app = tornado.web.Application(handlers=[(r"/", testClient)]) 
    http_server = tornado.httpserver.HTTPServer(app) 
    http_server.listen(options.port) 
    tornado.ioloop.IOLoop.instance().start()

Result:

[W 220916 22:30:49 web:2271] 404 GET /favicon.ico (::1) 0.30ms
0 Answers
Related