Closed eubinecto closed 4 years ago
# you can assign multiple routes to a function
# https://stackoverflow.com/questions/14032066/can-flask-have-optional-url-parameters
@app.route("/mongo/corpora_db/ml_gloss_coll")
@app.route("/mongo/corpora_db/ml_gloss_coll/<string:ml_gloss_id>")
@cross_origin()
def api_ml_gloss_coll(ml_gloss_id: Optional[str] = None):
corpora_db = CorporaDB()
if ml_gloss_id:
results = corpora_db.ml_gloss_coll.find_one(filter={"_id": ml_gloss_id})
else:
results = list(corpora_db.ml_gloss_coll.find())
return jsonify(results)
디비에 쿼리를 날려야 할 것.
왜?
135