fdropper 0.0.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- fdropper-0.0.1/.dockerignore +5 -0
- fdropper-0.0.1/.gitignore +4 -0
- fdropper-0.0.1/LICENSE +21 -0
- fdropper-0.0.1/PKG-INFO +9 -0
- fdropper-0.0.1/dockerfile +17 -0
- fdropper-0.0.1/fdropper.py +47 -0
- fdropper-0.0.1/pyproject.toml +17 -0
- fdropper-0.0.1/static/scripts/javascript.js +113 -0
- fdropper-0.0.1/static/styles/style.css +109 -0
- fdropper-0.0.1/templates/index.html +34 -0
fdropper-0.0.1/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) [2026] [Reece Williams]
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
fdropper-0.0.1/PKG-INFO
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
FROM python:3.14
|
|
2
|
+
WORKDIR /usr/local/dropper
|
|
3
|
+
|
|
4
|
+
COPY dropper-0.0.1-py2.py3-none-any.whl /
|
|
5
|
+
|
|
6
|
+
RUN pip install dropper-0.0.1-py2.py3-none-any.whl
|
|
7
|
+
|
|
8
|
+
COPY static ./static
|
|
9
|
+
COPY templates ./templates
|
|
10
|
+
RUN mkdir uploads
|
|
11
|
+
|
|
12
|
+
EXPOSE 8000
|
|
13
|
+
|
|
14
|
+
RUN useradd dropper
|
|
15
|
+
USER dropper
|
|
16
|
+
|
|
17
|
+
CMD ["gunicorn", "-w", "4", "-t", "120","-b" ,"0.0.0.0", "dropper:app"]
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import os
|
|
2
|
+
from flask import Flask, jsonify, render_template, request
|
|
3
|
+
from werkzeug.utils import secure_filename
|
|
4
|
+
|
|
5
|
+
UPLOAD_FOLDER = 'uploads'
|
|
6
|
+
|
|
7
|
+
app = Flask(__name__)
|
|
8
|
+
app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER
|
|
9
|
+
app.config['SECRET_KEY'] = 'your_very_secret_key'
|
|
10
|
+
|
|
11
|
+
if not os.path.exists(UPLOAD_FOLDER):
|
|
12
|
+
os.makedirs(UPLOAD_FOLDER)
|
|
13
|
+
|
|
14
|
+
@app.route('/', methods=['GET', 'POST'])
|
|
15
|
+
def upload_file():
|
|
16
|
+
if request.method == 'POST':
|
|
17
|
+
if 'file' not in request.files:
|
|
18
|
+
return jsonify(error='No files were included in the request.'), 400
|
|
19
|
+
|
|
20
|
+
files = request.files.getlist('file')
|
|
21
|
+
files = [file for file in files if file.filename]
|
|
22
|
+
if not files:
|
|
23
|
+
return jsonify(error='No files selected.'), 400
|
|
24
|
+
|
|
25
|
+
uploaded_files = []
|
|
26
|
+
for file in files:
|
|
27
|
+
filename = secure_filename(file.filename)
|
|
28
|
+
if not filename:
|
|
29
|
+
continue
|
|
30
|
+
|
|
31
|
+
base, extension = os.path.splitext(filename)
|
|
32
|
+
destination = os.path.join(app.config['UPLOAD_FOLDER'], filename)
|
|
33
|
+
counter = 1
|
|
34
|
+
while os.path.exists(destination):
|
|
35
|
+
filename = f'{base}_{counter}{extension}'
|
|
36
|
+
destination = os.path.join(app.config['UPLOAD_FOLDER'], filename)
|
|
37
|
+
counter += 1
|
|
38
|
+
|
|
39
|
+
file.save(destination)
|
|
40
|
+
uploaded_files.append(filename)
|
|
41
|
+
|
|
42
|
+
if not uploaded_files:
|
|
43
|
+
return jsonify(error='No valid filenames were supplied.'), 400
|
|
44
|
+
|
|
45
|
+
return jsonify(message='Files uploaded successfully.', files=uploaded_files), 201
|
|
46
|
+
|
|
47
|
+
return render_template('index.html',)
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling >= 1.26"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "fdropper"
|
|
7
|
+
version = "0.0.1"
|
|
8
|
+
dependencies = [
|
|
9
|
+
"Flask",
|
|
10
|
+
"gunicorn"
|
|
11
|
+
]
|
|
12
|
+
authors = [
|
|
13
|
+
{name = "Reece Williams"},
|
|
14
|
+
]
|
|
15
|
+
description = "A file uploader with frontend that can upload files directly to a share"
|
|
16
|
+
license = "MIT"
|
|
17
|
+
license-files = ["LICEN[CS]E*"]
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
const dropZone = document.getElementById("drop-zone");
|
|
2
|
+
const submitBtn = document.getElementById("submit-btn");
|
|
3
|
+
const fileInput = document.getElementById("file-input");
|
|
4
|
+
const preview = document.getElementById("preview");
|
|
5
|
+
const clearBtn = document.getElementById("clear-btn");
|
|
6
|
+
const uploadStatus = document.getElementById("upload-status");
|
|
7
|
+
let selectedFiles = [];
|
|
8
|
+
|
|
9
|
+
dropZone.addEventListener("dragover", (event) => {
|
|
10
|
+
event.preventDefault();
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
dropZone.addEventListener("drop", (event) => {
|
|
14
|
+
event.preventDefault();
|
|
15
|
+
|
|
16
|
+
addFiles(event.dataTransfer.files);
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
fileInput.addEventListener("change", (event) => {
|
|
20
|
+
addFiles(Array.from(event.target.files));
|
|
21
|
+
fileInput.value = "";
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
function addFiles(newFiles) {
|
|
25
|
+
for (const file of newFiles) {
|
|
26
|
+
const alreadyAdded = selectedFiles.some(
|
|
27
|
+
(existingFile) =>
|
|
28
|
+
existingFile.name === file.name &&
|
|
29
|
+
existingFile.size === file.size &&
|
|
30
|
+
existingFile.lastModified === file.lastModified
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
if (!alreadyAdded) {
|
|
34
|
+
selectedFiles.push(file);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
displayFiles(selectedFiles);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function displayFiles(files) {
|
|
42
|
+
clearPreview();
|
|
43
|
+
|
|
44
|
+
for (const file of files) {
|
|
45
|
+
const li = document.createElement("li");
|
|
46
|
+
|
|
47
|
+
if (file.type.startsWith("image/")) {
|
|
48
|
+
const img = document.createElement("img");
|
|
49
|
+
img.src = URL.createObjectURL(file);
|
|
50
|
+
img.alt = file.name;
|
|
51
|
+
li.appendChild(img);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
li.appendChild(document.createTextNode(file.name));
|
|
55
|
+
preview.appendChild(li);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function clearPreview() {
|
|
60
|
+
for (const img of preview.querySelectorAll("img")) {
|
|
61
|
+
URL.revokeObjectURL(img.src);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
preview.textContent = "";
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
async function uploadFiles(files) {
|
|
68
|
+
if (!files || files.length === 0) {
|
|
69
|
+
uploadStatus.textContent = "Choose at least one file before submitting.";
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const formData = new FormData();
|
|
74
|
+
|
|
75
|
+
for (const file of files) {
|
|
76
|
+
formData.append("file", file);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
try {
|
|
80
|
+
submitBtn.disabled = true;
|
|
81
|
+
uploadStatus.textContent = `Uploading ${files.length} file${files.length === 1 ? "" : "s"}...`;
|
|
82
|
+
const response = await fetch("/", {
|
|
83
|
+
method: "POST",
|
|
84
|
+
body: formData,
|
|
85
|
+
});
|
|
86
|
+
const result = await response.json();
|
|
87
|
+
|
|
88
|
+
if (response.ok) {
|
|
89
|
+
uploadStatus.textContent = `Uploaded ${result.files.length} file${result.files.length === 1 ? "" : "s"}: ${result.files.join(", ")}`;
|
|
90
|
+
clearPreview();
|
|
91
|
+
fileInput.value = "";
|
|
92
|
+
selectedFiles = [];
|
|
93
|
+
} else {
|
|
94
|
+
uploadStatus.textContent = result.error || "Upload failed.";
|
|
95
|
+
}
|
|
96
|
+
} catch (error) {
|
|
97
|
+
console.error("Error during upload:", error);
|
|
98
|
+
uploadStatus.textContent = "Upload failed. Please try again.";
|
|
99
|
+
} finally {
|
|
100
|
+
submitBtn.disabled = false;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
clearBtn.addEventListener("click", () => {
|
|
105
|
+
clearPreview();
|
|
106
|
+
fileInput.value = "";
|
|
107
|
+
selectedFiles = [];
|
|
108
|
+
uploadStatus.textContent = "";
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
submitBtn.addEventListener("click", () => {
|
|
112
|
+
uploadFiles(selectedFiles);
|
|
113
|
+
});
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
.silkscreen-regular {
|
|
2
|
+
font-family: "Silkscreen", sans-serif;
|
|
3
|
+
font-weight: 400;
|
|
4
|
+
font-style: normal;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.silkscreen-bold {
|
|
8
|
+
font-family: "Silkscreen", sans-serif;
|
|
9
|
+
font-weight: 700;
|
|
10
|
+
font-style: normal;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
body {
|
|
14
|
+
background-color: rgb(100, 146, 119);
|
|
15
|
+
color:rgb(255, 246, 240);
|
|
16
|
+
font-family: Silkscreen;
|
|
17
|
+
text-align: center;
|
|
18
|
+
overflow: hidden;
|
|
19
|
+
height: 100vh;
|
|
20
|
+
display: flex;
|
|
21
|
+
align-items: center;
|
|
22
|
+
justify-content: center;
|
|
23
|
+
flex-direction: column;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
button {
|
|
27
|
+
font-family: Silkscreen;
|
|
28
|
+
color:rgb(255, 246, 240);
|
|
29
|
+
background-color: rgb(39, 35, 35);
|
|
30
|
+
text-align: center;
|
|
31
|
+
margin-top: 5px;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.container {
|
|
35
|
+
display: flex;
|
|
36
|
+
justify-content: center;
|
|
37
|
+
align-items: stretch;
|
|
38
|
+
gap: 8px;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.preview-container {
|
|
42
|
+
display: flex;
|
|
43
|
+
flex-direction: column;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
h1 {
|
|
47
|
+
font-family: Silkscreen;
|
|
48
|
+
color:rgb(255, 246, 240);
|
|
49
|
+
text-align: center;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
#drop-zone {
|
|
53
|
+
display: flex;
|
|
54
|
+
align-items: center;
|
|
55
|
+
justify-content: center;
|
|
56
|
+
width: 500px;
|
|
57
|
+
max-width: 100%;
|
|
58
|
+
height: 200px;
|
|
59
|
+
padding: 1em;
|
|
60
|
+
border: 1px solid #cccccc;
|
|
61
|
+
border-radius: 4px;
|
|
62
|
+
color: rgb(255, 255, 255);
|
|
63
|
+
cursor: pointer;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
#file-input {
|
|
67
|
+
display: none;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
#preview {
|
|
71
|
+
min-width: 300px;
|
|
72
|
+
max-width: 500px;
|
|
73
|
+
display: flex;
|
|
74
|
+
flex-direction: column;
|
|
75
|
+
gap: 0.5em;
|
|
76
|
+
list-style: none;
|
|
77
|
+
padding: 10px;
|
|
78
|
+
border: 1px solid #cccccc;
|
|
79
|
+
border-radius: 4px;
|
|
80
|
+
flex: 1;
|
|
81
|
+
margin: 0;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
#preview li {
|
|
85
|
+
display: flex;
|
|
86
|
+
align-items: center;
|
|
87
|
+
gap: 0.5em;
|
|
88
|
+
margin: 0;
|
|
89
|
+
width: 100%;
|
|
90
|
+
height: 100px;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
#preview img {
|
|
94
|
+
width: 100px;
|
|
95
|
+
height: 100px;
|
|
96
|
+
object-fit: cover;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
button:disabled {
|
|
100
|
+
cursor: wait;
|
|
101
|
+
opacity: 0.65;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
#upload-status {
|
|
105
|
+
max-width: 500px;
|
|
106
|
+
min-height: 1.5em;
|
|
107
|
+
margin: 0.75em auto 0;
|
|
108
|
+
overflow-wrap: anywhere;
|
|
109
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<title>Dropper</title>
|
|
5
|
+
<link rel= "stylesheet" type= "text/css" href= "{{ url_for('static',filename='styles/style.css') }}">
|
|
6
|
+
<link rel="preconnect" href="https://fonts.googleapis.com">
|
|
7
|
+
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
|
8
|
+
<link href="https://fonts.googleapis.com/css2?family=Silkscreen:wght@400;700&display=swap" rel="stylesheet">
|
|
9
|
+
<link rel="shortcut icon" href="{{ url_for('static', filename='favicon.ico') }}">
|
|
10
|
+
<link rel="shortcut icon" href="{{ url_for('static', filename='apple-touch-icon.png') }}">
|
|
11
|
+
<link rel="shortcut icon" href="{{ url_for('static', filename='favicon-32x32.png') }}">
|
|
12
|
+
<link rel="shortcut icon" href="{{ url_for('static', filename='favicon-16x16.png') }}">
|
|
13
|
+
</head>
|
|
14
|
+
<body>
|
|
15
|
+
<div class="container">
|
|
16
|
+
<div>
|
|
17
|
+
<h1>Dropper</h1>
|
|
18
|
+
<label id="drop-zone">
|
|
19
|
+
Drop files here, or click to upload.
|
|
20
|
+
<input type="file" id="file-input" name="file" multiple>
|
|
21
|
+
</label>
|
|
22
|
+
<div>
|
|
23
|
+
<button id="clear-btn" type="button">Clear</button>
|
|
24
|
+
<button id="submit-btn" type="button">Submit</button>
|
|
25
|
+
</div>
|
|
26
|
+
<p id="upload-status" aria-live="polite"></p>
|
|
27
|
+
</div>
|
|
28
|
+
<div class="preview-container">
|
|
29
|
+
<ul id="preview"></ul>
|
|
30
|
+
</div>
|
|
31
|
+
</div>
|
|
32
|
+
<script src={{ url_for('static',filename='scripts/javascript.js') }}></script>
|
|
33
|
+
</body>
|
|
34
|
+
</html>
|