Something went wrong. Try again.
a link manager to create your mind library
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758from flask import Flask, jsonify, requestfrom flask_cors import CORS
app = Flask(__name__)CORS(app, resources={r"/api/*": {"origins": "*"}})
# In-memory data store for demo purposeslinks = [ { "id": 1, "url": "https://geohot.github.io/blog/jekyll/update/2024/10/28/americas-future.html", "title": "America's Future", "description": "how to achieve everything which I want", "image_url": "/images/placeholder.jpg", }, { "id": 2, "url": "https://example.com/attention-is-all-you-need", "title": "Attention Is All You Need", "description": "Transformer paper summary", "image_url": "/images/placeholder.jpg", },]next_id = 3
@app.get("/api/links")def get_links(): return jsonify({"links": links})
@app.post("/api/links")def add_link(): global next_id data = request.get_json(silent=True) or {}
url = data.get("url") title = data.get("title") or url description = data.get("description") or "" image_url = data.get("image_url") or "/images/placeholder.jpg"
if not url: return jsonify({"error": "url is required"}), 400
new_link = { "id": next_id, "url": url, "title": title, "description": description, "image_url": image_url, } links.append(new_link) next_id += 1 return jsonify(new_link), 201
if __name__ == "__main__": app.run(host="0.0.0.0", port=5001, debug=True)