3v324v23 commited on
Commit
10d75c6
·
1 Parent(s): c2dd918
Files changed (7) hide show
  1. Dockerfile +19 -0
  2. README.md +88 -5
  3. app.py +162 -0
  4. requirements.txt +3 -0
  5. templates/error.html +74 -0
  6. templates/index.html +145 -0
  7. templates/success.html +176 -0
Dockerfile ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.12-slim
2
+
3
+ WORKDIR /app
4
+
5
+ COPY requirements.txt .
6
+ RUN pip install --no-cache-dir -r requirements.txt
7
+
8
+ COPY app.py .
9
+ COPY templates/ templates/
10
+
11
+ # Hugging Face Spaces runs containers as a non-root user (uid 1000).
12
+ RUN useradd -m -u 1000 appuser && chown -R appuser /app
13
+ USER appuser
14
+
15
+ ENV PORT=7860
16
+
17
+ EXPOSE 7860
18
+
19
+ CMD ["gunicorn", "--bind", "0.0.0.0:7860", "--workers", "2", "--threads", "2", "app:app"]
README.md CHANGED
@@ -1,10 +1,93 @@
1
  ---
2
- title: Dropbox
3
- emoji: 🐢
4
- colorFrom: pink
5
- colorTo: yellow
6
  sdk: docker
 
7
  pinned: false
8
  ---
9
 
10
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ title: Dropbox Rclone
3
+ emoji: 📦
4
+ colorFrom: blue
5
+ colorTo: gray
6
  sdk: docker
7
+ app_port: 7860
8
  pinned: false
9
  ---
10
 
11
+ # dropbox-rclone
12
+
13
+ A Python web app that lets users generate their own **rclone Dropbox configs** using their own Dropbox app credentials. Multiple users can use the app simultaneously — each session is completely isolated.
14
+
15
+ ## How it works
16
+
17
+ 1. A user visits the app and enters their Dropbox **Client ID** (app key) and **Client Secret** (app secret).
18
+ 2. The app redirects them to Dropbox to authorise access.
19
+ 3. After authorisation, the app exchanges the code for tokens and generates a ready-to-use rclone config block.
20
+ 4. The user copies the config into their rclone config file.
21
+
22
+ ## Prerequisites
23
+
24
+ - Python 3.9+
25
+ - A Dropbox app ([App Console](https://www.dropbox.com/developers/apps))
26
+
27
+ ## Dropbox app setup
28
+
29
+ 1. Create an app in the [Dropbox App Console](https://www.dropbox.com/developers/apps).
30
+ 2. Under **OAuth 2 → Redirect URIs**, add the callback URL for your deployment, e.g.:
31
+ - Local development: `http://localhost:5000/callback`
32
+ - Production: `https://your-domain.com/callback`
33
+ 3. Note the **App key** (Client ID) and **App secret** (Client Secret).
34
+
35
+ ## Running locally
36
+
37
+ ```bash
38
+ pip install -r requirements.txt
39
+
40
+ # Optional but recommended in production:
41
+ export SECRET_KEY="$(python -c 'import secrets; print(secrets.token_hex(32))')"
42
+
43
+ python app.py
44
+ # → http://localhost:5000
45
+ ```
46
+
47
+ ## Running with Gunicorn (recommended for production)
48
+
49
+ ```bash
50
+ export SECRET_KEY="a-long-random-string"
51
+ export PORT=7860
52
+
53
+ gunicorn --bind 0.0.0.0:$PORT --workers 2 --threads 2 app:app
54
+ ```
55
+
56
+ ## Docker
57
+
58
+ ```bash
59
+ docker build -t dropbox-rclone .
60
+ docker run -p 7860:7860 -e SECRET_KEY="a-long-random-string" dropbox-rclone
61
+ ```
62
+
63
+ ## Hugging Face Spaces
64
+
65
+ This repository is ready to deploy on [Hugging Face Spaces](https://huggingface.co/spaces) (free tier) using the Docker SDK.
66
+
67
+ 1. Create a new Space on Hugging Face and choose **Docker** as the SDK.
68
+ 2. Push this repository (or the `copilot/deploy-to-hugging-face` branch) to the Space.
69
+ 3. In the Space **Settings → Repository secrets**, add a `SECRET_KEY` secret with a long random value:
70
+ ```
71
+ python -c "import secrets; print(secrets.token_hex(32))"
72
+ ```
73
+ 4. In your Dropbox app's **OAuth 2 → Redirect URIs**, add:
74
+ ```
75
+ https://<your-space-owner>-<your-space-name>.hf.space/callback
76
+ ```
77
+ The Space URL is shown on the Space overview page.
78
+ 5. Hugging Face will build and start the container automatically. The app will be available at `https://<your-space-owner>-<your-space-name>.hf.space`.
79
+
80
+ ## Environment variables
81
+
82
+ | Variable | Default | Description |
83
+ |--------------|----------------------|---------------------------------------------------|
84
+ | `SECRET_KEY` | random (per restart) | Secret key for signing session cookies. **Set this in production.** |
85
+ | `PORT` | `5000` | Port to listen on when running with `python app.py` |
86
+
87
+ > **Security note:** Set a stable `SECRET_KEY` in production. Without it, a new random key is generated on every process start, which:
88
+ > - Invalidates all existing sessions on restart.
89
+ > - Causes session validation failures when using multiple Gunicorn workers (each worker gets its own random key). This will break the OAuth flow for most users in a multi-worker setup.
90
+
91
+ ## Concurrency
92
+
93
+ The app stores all per-user state in signed, server-side session cookies, so there is no shared mutable state between requests. It scales horizontally — run as many Gunicorn workers or container replicas as you need.
app.py ADDED
@@ -0,0 +1,162 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Dropbox rclone config generator web app.
3
+
4
+ Allows multiple users to simultaneously create their own rclone configs
5
+ using their own Dropbox app client IDs and secrets via OAuth2.
6
+ """
7
+
8
+ import json
9
+ import os
10
+ import secrets
11
+ from urllib.parse import urlencode
12
+
13
+ import requests
14
+ from flask import (
15
+ Flask,
16
+ redirect,
17
+ render_template,
18
+ request,
19
+ session,
20
+ url_for,
21
+ )
22
+
23
+ app = Flask(__name__)
24
+
25
+ # Secret key for signing session cookies. In production, set the
26
+ # SECRET_KEY environment variable to a long, random string.
27
+ app.secret_key = os.environ.get("SECRET_KEY", secrets.token_hex(32))
28
+
29
+ DROPBOX_AUTH_URL = "https://www.dropbox.com/oauth2/authorize"
30
+ DROPBOX_TOKEN_URL = "https://api.dropboxapi.com/oauth2/token"
31
+
32
+
33
+ @app.route("/", methods=["GET"])
34
+ def index():
35
+ callback_url = url_for("callback", _external=True)
36
+ return render_template("index.html", callback_url=callback_url)
37
+
38
+
39
+ @app.route("/start", methods=["POST"])
40
+ def start():
41
+ client_id = request.form.get("client_id", "").strip()
42
+ client_secret = request.form.get("client_secret", "").strip()
43
+
44
+ if not client_id or not client_secret:
45
+ return render_template(
46
+ "error.html",
47
+ message="Both Client ID and Client Secret are required.",
48
+ )
49
+
50
+ # Generate a unique state token to tie this OAuth flow to this session
51
+ # and prevent CSRF attacks.
52
+ state = secrets.token_urlsafe(32)
53
+
54
+ # Store credentials and state in the signed session cookie so that each
55
+ # concurrent user has their own isolated state.
56
+ session["client_id"] = client_id
57
+ session["client_secret"] = client_secret
58
+ session["oauth_state"] = state
59
+
60
+ # Build the redirect URI based on the current request's base URL so the
61
+ # app works regardless of where it is deployed.
62
+ redirect_uri = url_for("callback", _external=True)
63
+
64
+ params = {
65
+ "response_type": "code",
66
+ "client_id": client_id,
67
+ "redirect_uri": redirect_uri,
68
+ "state": state,
69
+ "token_access_type": "offline", # request a refresh token
70
+ }
71
+
72
+ auth_url = f"{DROPBOX_AUTH_URL}?{urlencode(params)}"
73
+ return redirect(auth_url)
74
+
75
+
76
+ @app.route("/callback")
77
+ def callback():
78
+ error = request.args.get("error")
79
+ if error:
80
+ error_description = request.args.get("error_description", error)
81
+ return render_template("error.html", message=error_description)
82
+
83
+ code = request.args.get("code")
84
+ returned_state = request.args.get("state")
85
+
86
+ # Validate state to prevent CSRF
87
+ expected_state = session.get("oauth_state")
88
+ if not expected_state or returned_state != expected_state:
89
+ return render_template(
90
+ "error.html",
91
+ message="Invalid or expired session. Please start over.",
92
+ )
93
+
94
+ client_id = session.get("client_id")
95
+ client_secret = session.get("client_secret")
96
+
97
+ if not client_id or not client_secret:
98
+ return render_template(
99
+ "error.html",
100
+ message="Session data missing. Please start over.",
101
+ )
102
+
103
+ redirect_uri = url_for("callback", _external=True)
104
+
105
+ # Exchange the authorization code for tokens
106
+ try:
107
+ resp = requests.post(
108
+ DROPBOX_TOKEN_URL,
109
+ data={
110
+ "code": code,
111
+ "grant_type": "authorization_code",
112
+ "redirect_uri": redirect_uri,
113
+ },
114
+ auth=(client_id, client_secret),
115
+ timeout=15,
116
+ )
117
+ resp.raise_for_status()
118
+ except requests.RequestException as exc:
119
+ app.logger.error("Token exchange failed: %s", exc)
120
+ return render_template(
121
+ "error.html",
122
+ message=(
123
+ "Failed to connect to Dropbox. "
124
+ "Please check your credentials and try again."
125
+ ),
126
+ )
127
+
128
+ token_data = resp.json()
129
+
130
+ if "error" in token_data:
131
+ return render_template(
132
+ "error.html",
133
+ message=token_data.get("error_description", token_data["error"]),
134
+ )
135
+
136
+ # Build the rclone token JSON that rclone expects
137
+ rclone_token = json.dumps(
138
+ {
139
+ "access_token": token_data.get("access_token", ""),
140
+ "token_type": token_data.get("token_type", "bearer"),
141
+ "refresh_token": token_data.get("refresh_token", ""),
142
+ "expiry": "0001-01-01T00:00:00Z",
143
+ }
144
+ )
145
+
146
+ config = (
147
+ "[dropbox]\n"
148
+ "type = dropbox\n"
149
+ f"client_id = {client_id}\n"
150
+ f"client_secret = {client_secret}\n"
151
+ f"token = {rclone_token}\n"
152
+ )
153
+
154
+ # Clear sensitive session data after successful use
155
+ session.clear()
156
+
157
+ return render_template("success.html", config=config)
158
+
159
+
160
+ if __name__ == "__main__":
161
+ port = int(os.environ.get("PORT", 5000))
162
+ app.run(host="0.0.0.0", port=port, debug=False)
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ Flask==3.1.3
2
+ gunicorn==25.1.0
3
+ requests==2.31.0
templates/error.html ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
+ <title>Error — Dropbox rclone</title>
7
+ <style>
8
+ *, *::before, *::after { box-sizing: border-box; }
9
+
10
+ body {
11
+ font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
12
+ background: #f0f2f5;
13
+ margin: 0;
14
+ display: flex;
15
+ justify-content: center;
16
+ align-items: center;
17
+ min-height: 100vh;
18
+ padding: 1rem;
19
+ }
20
+
21
+ .card {
22
+ background: #fff;
23
+ border-radius: 10px;
24
+ box-shadow: 0 4px 20px rgba(0,0,0,.1);
25
+ padding: 2.5rem;
26
+ max-width: 480px;
27
+ width: 100%;
28
+ text-align: center;
29
+ }
30
+
31
+ .icon { font-size: 2.5rem; margin-bottom: .5rem; }
32
+
33
+ h1 {
34
+ font-size: 1.4rem;
35
+ color: #cf222e;
36
+ margin: 0 0 1rem;
37
+ }
38
+
39
+ .message {
40
+ background: #fff0ee;
41
+ border: 1px solid #ffcdd2;
42
+ border-radius: 6px;
43
+ padding: 1rem;
44
+ color: #5c1a1a;
45
+ font-size: .9rem;
46
+ margin-bottom: 1.5rem;
47
+ text-align: left;
48
+ word-break: break-word;
49
+ }
50
+
51
+ a.btn {
52
+ display: inline-block;
53
+ padding: .65rem 1.5rem;
54
+ background: #0061ff;
55
+ color: #fff;
56
+ border-radius: 6px;
57
+ text-decoration: none;
58
+ font-weight: 600;
59
+ font-size: .95rem;
60
+ transition: background .2s;
61
+ }
62
+
63
+ a.btn:hover { background: #0050d0; }
64
+ </style>
65
+ </head>
66
+ <body>
67
+ <div class="card">
68
+ <div class="icon">❌</div>
69
+ <h1>Something went wrong</h1>
70
+ <div class="message">{{ message }}</div>
71
+ <a class="btn" href="/">← Try again</a>
72
+ </div>
73
+ </body>
74
+ </html>
templates/index.html ADDED
@@ -0,0 +1,145 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
+ <title>Dropbox rclone Config Generator</title>
7
+ <style>
8
+ *, *::before, *::after { box-sizing: border-box; }
9
+
10
+ body {
11
+ font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
12
+ background: #f0f2f5;
13
+ margin: 0;
14
+ display: flex;
15
+ justify-content: center;
16
+ align-items: center;
17
+ min-height: 100vh;
18
+ padding: 1rem;
19
+ }
20
+
21
+ .card {
22
+ background: #fff;
23
+ border-radius: 10px;
24
+ box-shadow: 0 4px 20px rgba(0,0,0,.1);
25
+ padding: 2.5rem;
26
+ max-width: 480px;
27
+ width: 100%;
28
+ }
29
+
30
+ .logo { font-size: 2.5rem; text-align: center; margin-bottom: .5rem; }
31
+
32
+ h1 {
33
+ text-align: center;
34
+ font-size: 1.4rem;
35
+ color: #1a1a2e;
36
+ margin: 0 0 .5rem;
37
+ }
38
+
39
+ p.subtitle {
40
+ text-align: center;
41
+ color: #666;
42
+ font-size: .9rem;
43
+ margin: 0 0 2rem;
44
+ }
45
+
46
+ label {
47
+ display: block;
48
+ font-weight: 600;
49
+ font-size: .875rem;
50
+ color: #333;
51
+ margin-bottom: .35rem;
52
+ }
53
+
54
+ input[type="text"],
55
+ input[type="password"] {
56
+ width: 100%;
57
+ padding: .65rem .9rem;
58
+ border: 1px solid #ccc;
59
+ border-radius: 6px;
60
+ font-size: .95rem;
61
+ transition: border-color .2s;
62
+ margin-bottom: 1.2rem;
63
+ }
64
+
65
+ input:focus {
66
+ outline: none;
67
+ border-color: #0061ff;
68
+ }
69
+
70
+ button[type="submit"] {
71
+ width: 100%;
72
+ padding: .75rem;
73
+ background: #0061ff;
74
+ color: #fff;
75
+ border: none;
76
+ border-radius: 6px;
77
+ font-size: 1rem;
78
+ font-weight: 600;
79
+ cursor: pointer;
80
+ transition: background .2s;
81
+ }
82
+
83
+ button[type="submit"]:hover { background: #0050d0; }
84
+
85
+ .help {
86
+ margin-top: 1.5rem;
87
+ padding: 1rem;
88
+ background: #f8f9fa;
89
+ border-radius: 6px;
90
+ font-size: .82rem;
91
+ color: #555;
92
+ line-height: 1.6;
93
+ }
94
+
95
+ .help a { color: #0061ff; text-decoration: none; }
96
+ .help a:hover { text-decoration: underline; }
97
+ </style>
98
+ </head>
99
+ <body>
100
+ <div class="card">
101
+ <div class="logo">📦</div>
102
+ <h1>Dropbox rclone Config Generator</h1>
103
+ <p class="subtitle">
104
+ Enter your Dropbox app credentials to generate an rclone config file.
105
+ </p>
106
+
107
+ <form action="/start" method="post">
108
+ <label for="client_id">Client ID</label>
109
+ <input
110
+ type="text"
111
+ id="client_id"
112
+ name="client_id"
113
+ placeholder="Your Dropbox app key"
114
+ required
115
+ autocomplete="off"
116
+ />
117
+
118
+ <label for="client_secret">Client Secret</label>
119
+ <input
120
+ type="password"
121
+ id="client_secret"
122
+ name="client_secret"
123
+ placeholder="Your Dropbox app secret"
124
+ required
125
+ autocomplete="off"
126
+ />
127
+
128
+ <button type="submit">Authorize with Dropbox →</button>
129
+ </form>
130
+
131
+ <div class="help">
132
+ <strong>How to get your credentials:</strong><br />
133
+ 1. Go to the
134
+ <a href="https://www.dropbox.com/developers/apps" target="_blank" rel="noopener noreferrer">
135
+ Dropbox App Console
136
+ </a>.<br />
137
+ 2. Create a new app (Full Dropbox or App folder access).<br />
138
+ 3. Add <code>{{ callback_url }}</code> to the
139
+ <em>Redirect URIs</em> list in your app settings.<br />
140
+ 4. Copy the <em>App key</em> (Client ID) and
141
+ <em>App secret</em> (Client Secret) here.
142
+ </div>
143
+ </div>
144
+ </body>
145
+ </html>
templates/success.html ADDED
@@ -0,0 +1,176 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
+ <title>Config Generated — Dropbox rclone</title>
7
+ <style>
8
+ *, *::before, *::after { box-sizing: border-box; }
9
+
10
+ body {
11
+ font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
12
+ background: #f0f2f5;
13
+ margin: 0;
14
+ display: flex;
15
+ justify-content: center;
16
+ align-items: flex-start;
17
+ min-height: 100vh;
18
+ padding: 2rem 1rem;
19
+ }
20
+
21
+ .card {
22
+ background: #fff;
23
+ border-radius: 10px;
24
+ box-shadow: 0 4px 20px rgba(0,0,0,.1);
25
+ padding: 2.5rem;
26
+ max-width: 600px;
27
+ width: 100%;
28
+ }
29
+
30
+ .icon { font-size: 2.5rem; text-align: center; margin-bottom: .5rem; }
31
+
32
+ h1 {
33
+ text-align: center;
34
+ font-size: 1.4rem;
35
+ color: #1a7f37;
36
+ margin: 0 0 .5rem;
37
+ }
38
+
39
+ p.subtitle {
40
+ text-align: center;
41
+ color: #666;
42
+ font-size: .9rem;
43
+ margin: 0 0 2rem;
44
+ }
45
+
46
+ pre {
47
+ background: #1e1e2e;
48
+ color: #cdd6f4;
49
+ padding: 1.25rem 1.5rem;
50
+ border-radius: 8px;
51
+ font-size: .85rem;
52
+ overflow-x: auto;
53
+ white-space: pre;
54
+ line-height: 1.6;
55
+ margin-bottom: 1rem;
56
+ position: relative;
57
+ }
58
+
59
+ .copy-btn {
60
+ display: block;
61
+ width: 100%;
62
+ padding: .65rem;
63
+ background: #0061ff;
64
+ color: #fff;
65
+ border: none;
66
+ border-radius: 6px;
67
+ font-size: .95rem;
68
+ font-weight: 600;
69
+ cursor: pointer;
70
+ transition: background .2s;
71
+ margin-bottom: 1.5rem;
72
+ }
73
+
74
+ .copy-btn:hover { background: #0050d0; }
75
+ .copy-btn.copied { background: #1a7f37; }
76
+
77
+ .instructions {
78
+ background: #f8f9fa;
79
+ border-radius: 6px;
80
+ padding: 1rem 1.25rem;
81
+ font-size: .85rem;
82
+ color: #555;
83
+ line-height: 1.8;
84
+ }
85
+
86
+ .instructions code {
87
+ background: #e9ecef;
88
+ padding: .1rem .35rem;
89
+ border-radius: 4px;
90
+ font-family: monospace;
91
+ }
92
+
93
+ .back-link {
94
+ display: block;
95
+ text-align: center;
96
+ margin-top: 1.5rem;
97
+ color: #0061ff;
98
+ text-decoration: none;
99
+ font-size: .9rem;
100
+ }
101
+
102
+ .back-link:hover { text-decoration: underline; }
103
+ </style>
104
+ </head>
105
+ <body>
106
+ <div class="card">
107
+ <div class="icon">✅</div>
108
+ <h1>Config Generated Successfully</h1>
109
+ <p class="subtitle">
110
+ Copy the config below and paste it into your rclone configuration file.
111
+ </p>
112
+
113
+ <pre id="config-output">{{ config }}</pre>
114
+
115
+ <button class="copy-btn" id="copy-btn" onclick="copyConfig()">
116
+ Copy to clipboard
117
+ </button>
118
+
119
+ <div class="instructions">
120
+ <strong>Next steps:</strong><br />
121
+ 1. Open (or create) your rclone config:
122
+ <code>rclone config file</code><br />
123
+ 2. Paste the block above at the end of the file.<br />
124
+ 3. Test with: <code>rclone ls dropbox:</code><br />
125
+ 4. Keep this config safe — it contains your credentials.
126
+ </div>
127
+
128
+ <a class="back-link" href="/">← Generate another config</a>
129
+ </div>
130
+
131
+ <script>
132
+ function copyConfig() {
133
+ const text = document.getElementById("config-output").textContent;
134
+ const btn = document.getElementById("copy-btn");
135
+
136
+ if (navigator.clipboard && navigator.clipboard.writeText) {
137
+ navigator.clipboard.writeText(text).then(function () {
138
+ btn.textContent = "Copied!";
139
+ btn.classList.add("copied");
140
+ setTimeout(function () {
141
+ btn.textContent = "Copy to clipboard";
142
+ btn.classList.remove("copied");
143
+ }, 2000);
144
+ }).catch(function () {
145
+ fallbackCopy(text, btn);
146
+ });
147
+ } else {
148
+ fallbackCopy(text, btn);
149
+ }
150
+ }
151
+
152
+ function fallbackCopy(text, btn) {
153
+ const textarea = document.createElement("textarea");
154
+ textarea.value = text;
155
+ textarea.style.position = "fixed";
156
+ textarea.style.opacity = "0";
157
+ document.body.appendChild(textarea);
158
+ textarea.focus();
159
+ textarea.select();
160
+ try {
161
+ document.execCommand("copy");
162
+ btn.textContent = "Copied!";
163
+ btn.classList.add("copied");
164
+ setTimeout(function () {
165
+ btn.textContent = "Copy to clipboard";
166
+ btn.classList.remove("copied");
167
+ }, 2000);
168
+ } catch (err) {
169
+ btn.textContent = "Copy failed — select manually";
170
+ } finally {
171
+ document.body.removeChild(textarea);
172
+ }
173
+ }
174
+ </script>
175
+ </body>
176
+ </html>