2 # Copyright (C) 2018 rubenwardy
4 # This program is free software: you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation, either version 3 of the License, or
7 # (at your option) any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program. If not, see <https://www.gnu.org/licenses/>.
19 from flask_user import *
21 from app.models import *
22 from app.utils import is_package_page
23 from .packages import build_packages_query
25 @app.route("/api/packages/")
26 def api_packages_page():
27 query, _ = build_packages_query()
28 pkgs = [package.getAsDictionaryShort(app.config["BASE_URL"]) \
29 for package in query.all() if package.getDownloadRelease() is not None]
32 @app.route("/api/packages/<author>/<name>/")
34 def api_package_page(package):
35 return jsonify(package.getAsDictionary(app.config["BASE_URL"]))