Skip to content
Sign upLog in
This post is read-only. Explore Repls and connect with other creators on Community.View Community
The info in this post might be out of date, check out our docs instead. View docs
2

Can someone help me disable cors policy so other repls can access my database?

from flask import *
from replit import db

app = Flask(name)

@app
.route("/set///")
def set(name, data):
print(name + " = " + data)
db[name] = data
return ""

@app
.route("/get//")
def get(name):
return db[name]

app.run(host="0.0.0.0", debug=True)

1 year ago

Voters

KawalPreetPreet
KawalPreetPreet
JoseCarlosDJesu
JoseCarlosDJesu

Comments

TopNew
2
ch1ck3n
ch1ck3n
  1. what you're trying to do is ENABLE cors

and here is your code mate

from flask import * from flask_cors import CORS from replit import db app = Flask(__name__) cors = CORS(app) app.config['CORS_HEADERS'] = 'Content-Type' @app.route("/set/<name>/<data>/") def set(name, data): print(name + " = " + data) db[name] = data return "" @app.route("/get/<name>/") def get(name): return db[name] app.run(host="0.0.0.0", debug=True)
1 year ago
1
SixBeeps
SixBeeps
# First we need the CORS thinymajig from flask_cors import CORS, cross_origin # Put this right after you declare the app cors = CORS(app)
1 year ago
Load more