diff --git a/app.py b/app.py index 6b7df1b..aa77674 100644 --- a/app.py +++ b/app.py @@ -1222,6 +1222,20 @@ def is_valid_password(password): banned_passwords = ['info', 'download'] return password not in banned_passwords +@app.route('/reset_api_key', methods=['POST']) +@login_required +def reset_api_key(): + new_api_key = secrets.token_urlsafe(32) + db = get_db() + cursor = db.cursor() + cursor.execute("UPDATE users SET api_key = ? WHERE id = ?", (new_api_key, current_user.id)) + db.commit() + return jsonify({'success': True, 'new_api_key': new_api_key}) + +@app.route('/api/docs') +def api_docs(): + return render_template('api_docs.html') + if __name__ == '__main__': # Start the cleanup thread cleanup_thread = threading.Thread(target=delete_old_files) diff --git a/templates/api_docs.html b/templates/api_docs.html new file mode 100644 index 0000000..2cc5d85 --- /dev/null +++ b/templates/api_docs.html @@ -0,0 +1,62 @@ + + +
+ + +All API requests require an API key to be sent in the X-API-Key header.
+ ++POST /api/upload/file +Headers: + X-API-Key: your_api_key +Body: multipart/form-data + file: (binary) ++
Returns: JSON with file URL and deletion URL
+ ++POST /api/upload/pastebin +Headers: + X-API-Key: your_api_key + Content-Type: application/json +Body: +{ + "content": "Your pastebin content here" +} ++
Returns: JSON with pastebin URL and deletion URL
+ ++POST /api/shorten +Headers: + X-API-Key: your_api_key + Content-Type: application/json +Body: +{ + "url": "https://example.com/your-long-url-here" +} ++
Returns: JSON with shortened URL and deletion URL
+ +All errors are returned as JSON with an "error" field describing the issue.
+ + + + \ No newline at end of file diff --git a/templates/user_files.html b/templates/user_files.html index c59d061..363e90a 100644 --- a/templates/user_files.html +++ b/templates/user_files.html @@ -881,7 +881,7 @@