From 6bd4addc9c7a1fc42294045ba712e0980991cb80 Mon Sep 17 00:00:00 2001 From: Dan Dembinski Date: Thu, 16 Apr 2020 21:40:50 -0400 Subject: [PATCH] Added method to manually add a manga without uploading a new json file. Just need to pass a "name" and "url" node. URL must include http or https. --- main.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/main.py b/main.py index 45b675c..c6ae702 100644 --- a/main.py +++ b/main.py @@ -147,7 +147,23 @@ def check(passin=0): else: return jsonify(missingFlags=missingFlags, missingManga=missingManga) -@app.route('/upgrade/', methods=['Put']) +@app.route('/add/', methods=['PUT']) +def add(): + data = request.get_json() + added = [] + + if 'http' or 'https' not in data['url']: + return jsonify(error='invalid url') + if not manga.query.filter_by(name=data['name']).first(): + new_manga={} + query = manga(name=data['name'], url=data['url'], url_flag='000000', view_format=0, unknown_value=0) + new_manga['title'] = data['name'] + added.append(new_manga) + db.session.add(query) + db.session.commit() + return jsonify(added=added) + +@app.route('/upgrade/', methods=['PUT']) def upgrade(): os.system('pip install --upgrade manga-py') return jsonify(status='manga-py upgrade ran')