roundabout,
created on Tuesday, 19 November 2024, 16:32:05 (1732033925),
received on Tuesday, 19 November 2024, 16:32:08 (1732033928)
Author identity: vlad <vlad.muntoiu@gmail.com>
e9fa03ca2e2b01b8833599db95f72634508b3587
api.py
@@ -62,4 +62,18 @@ def get_user_repositories(username):
return response @api_app.route("/repo/<username>/<repository>/", methods=["GET"]) @auth.login_required(optional=True) def get_repository(username, repository): user = db.session.get(User, username) repo_data = db.session.get(Repo, f"/{username}/{repository}") if not (repo_data.visibility or RepoAccess.query.filter_by(user=user, repo=repo_data).first()): return flask.Response("", 401, content_type="text/plain") response = flask.make_response(flask.render_template("repository.xml", repository=repo_data)) response.headers["Content-Type"] = "application/xml" return response app.register_blueprint(api_app)
templates/api/repository.xml
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8" ?> <repository owner="{{ repository.owner.username }}" name="{{ repository.name }}" visibility="{{ repository.visibility }}" has-site="{{ repository.has_site }}"> <description>{{ repository.info }}</description> <url>{{ repository.url }}</url> <date>{{ repository.creation_date }}</date> <default-branch>{{ repository.default_branch }}</default-branch> </repository>