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 @@ + + + + + + API Documentation - sxbin + + + +

sxbin API Documentation

+ +

Authentication

+

All API requests require an API key to be sent in the X-API-Key header.

+ +

Endpoints

+ +

Upload File

+
+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

+ +

Upload Pastebin

+
+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

+ +

Shorten 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

+ +

Error Handling

+

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 @@
- +
@@ -985,10 +985,33 @@
-
-

ShareX Configuration

-

Click the button below to download your ShareX configuration file:

- Download ShareX Config +
+

API Key & ShareX

+ +
+

ShareX Configuration

+

Download the ShareX configuration file to easily integrate with our service:

+ Download ShareX Config +
+ +
+

Your API Key

+

API Key: {{ current_user.api_key }}

+ +
+
+ + +
@@ -1589,6 +1612,22 @@ .file-group-link a:hover { text-decoration: underline; } + + .blurred { + filter: blur(5px); + transition: filter 0.3s ease; + } + + .blurred:hover { + filter: blur(0); + } + + .api-key-section, .sharex-config-section { + margin-bottom: 20px; + padding: 15px; + background-color: var(--highlight-bg); + border-radius: 5px; + } \ No newline at end of file