server.py 628 B

12345678910111213141516171819202122
  1. from flask import Flask, request, jsonify
  2. import execjs
  3. import urllib.parse
  4. app = Flask(__name__)
  5. @app.route('/X-Bogus', methods=['POST'])
  6. def generate_request_params():
  7. data = request.get_json()
  8. url = data.get('url')
  9. user_agent = data.get('user_agent')
  10. query = urllib.parse.urlparse(url).query
  11. xbogus = execjs.compile(open('./X-Bogus.js').read()).call('sign', query, user_agent)
  12. new_url = url + "&X-Bogus=" + xbogus
  13. response_data = {
  14. "param": new_url,
  15. "X-Bogus": xbogus
  16. }
  17. return jsonify(response_data)
  18. if __name__ == '__main__':
  19. app.run(host='0.0.0.0', port=8787)