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.
This commit is contained in:
18
main.py
18
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')
|
||||
|
||||
Reference in New Issue
Block a user