How to pass variable from python to javascript

前端 未结 2 1236
说谎
说谎 2021-01-26 11:13

I have a server in python to process an id (the id of youtube video), this is the code:

class MessageHandler(tornado.web.RequestHandler): 
  def get(self, action         


        
2条回答
  •  自闭症患者
    2021-01-26 11:39

    If you are using a Python framework like Flask, you can access the value of action_id using a template engine like Jinja2 (see http://flask.pocoo.org/docs/0.10/quickstart/#rendering-templates).

    Otherwise, to access the action_id using javascript you can use an AJAX call, which is an asynchronous javascript request to your Python web server (see http://api.jquery.com/jquery.ajax/). Note that the .ajax call is part of the JQuery library, but this can also be done without it.

提交回复
热议问题