SimpleDao
Python bottle解决跨域问题
2019-05-06, 访问数: 1229

同意跨域

  1. from bottle import route, run, template, Bottle, response
  2. app = Bottle()
  3. @app.hook('after_request')
  4. def enable_cors():
  5. response.headers['Access-Control-Allow-Origin'] = '*'
  6. response.headers['Access-Control-Allow-Methods'] = 'GET, POST, PUT, OPTIONS'
  7. response.headers['Access-Control-Allow-Headers'] = 'Origin, Accept, Content-Type, X-Requested-With, X-CSRF-Token'