DEV Community

loading...

Discussion on: Fast way to enable CORS in Flask servers

Collapse
wasosky11 profile image
Wasosky

File "/home/pelu/Projects/PythonFlask/src/app.py", line 103, in
@cross_origin()
NameError: name 'cross_origin' is not defined

Collapse
sahil13399 profile image
sahil-13399

I'm getting this same error, did you find any solution?

Collapse
wasosky11 profile image
Wasosky

No yet, if you found any solution please contact me, wasosky313@gmail.com

Collapse
hidialgo profile image
Hashan Mahesh

you need to import it first

"from flask_cors import cross_origin"

Collapse
rajojon23 profile image
rajojon23

I had the same issue. I ended up using the code from the flask cors documentation:

from flask import Flask
from flask_cors import CORS

app = Flask(name)
CORS(app)

@app.route("/")
def helloWorld():
return "Hello, cross-origin-world!"