roundabout,
created on Monday, 9 September 2024, 11:03:43 (1725879823),
received on Monday, 9 September 2024, 14:10:32 (1725891032)
Author identity: vlad <vlad.muntoiu@gmail.com>
f21ef33c63c97c4d036907b7625187b61b7d58bb
app.py
@@ -92,7 +92,7 @@ with app.app_context():
id = db.Column(db.String(64), primary_key=True) # SPDX identifier title = db.Column(db.UnicodeText, nullable=False) # the official name of the licence description = db.Column(db.UnicodeText, nullable=False) # brief description of its permissions and restrictions info_url = db.Column(db.String(1024), nullable=False) # the URL to a page with general information about the licenceinfo_url = db.Column(db.String(1024), nullable=False) # the URL to a page with general information about the licenceurl = db.Column(db.String(1024), nullable=True) # the URL to a page with the full text of the licence and more information pictures = db.relationship("PictureLicence", back_populates="licence") free = db.Column(db.Boolean, nullable=False, default=False) # whether the licence is free or not
@@ -875,9 +875,7 @@ def query_pictures():
json_resources.append(json_resource) response = flask.jsonify(json_response)response.headers["Content-Type"] = "application/json"return responsereturn flask.jsonify(json_response)@app.route("/api/picture/<int:id>/")
@@ -910,7 +908,80 @@ def api_picture(id):
"shape": region.json["shape"], }) response = flask.jsonify(json_resource)response.headers["Content-Type"] = "application/json"return responsereturn flask.jsonify(json_resource) @app.route("/api/licence/") def api_licences(): licences = db.session.query(Licence).all() json_licences = { licence.id: { "title": licence.title, "free": licence.free, "pinned": licence.pinned, } for licence in licences } return flask.jsonify(json_licences) @app.route("/api/licence/<id>/") def api_licence(id): licence = db.session.get(Licence, id) if licence is None: flask.abort(404) json_licence = { "id": licence.id, "title": licence.title, "description": licence.description, "info_url": licence.info_url, "legalese_url": licence.url, "free": licence.free, "logo_url": licence.logo_url, "pinned": licence.pinned, } return flask.jsonify(json_licence) @app.route("/api/nature/") def api_natures(): natures = db.session.query(PictureNature).all() json_natures = { nature.id: nature.description for nature in natures } return flask.jsonify(json_natures) @app.route("/api/user/") def api_users(): offset = int(flask.request.args.get("offset", 0)) limit = int(flask.request.args.get("limit", 16)) users = db.session.query(User).offset(offset).limit(limit).all() json_users = { user.username: { "admin": user.admin, } for user in users } return flask.jsonify(json_users) @app.route("/api/user/<username>/") def api_user(username): user = db.session.get(User, username) if user is None: flask.abort(404) json_user = { "username": user.username, "admin": user.admin, "joined": user.joined_timestamp.timestamp(), } return flask.jsonify(json_user)