dropit 0.1.0__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.
dropit-0.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Darshan P.
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.
@@ -0,0 +1,4 @@
1
+ include LICENSE
2
+ include README.md
3
+ recursive-include dropit/static *
4
+ recursive-include dropit/templates *
dropit-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,36 @@
1
+ Metadata-Version: 2.1
2
+ Name: dropit
3
+ Version: 0.1.0
4
+ Summary: A Flask-based command line file sharing application.
5
+ Home-page: https://github.com/1darshanpatil/dropit
6
+ Author: Darshan P.
7
+ Author-email: drshnp@outlook.com
8
+ License: UNKNOWN
9
+ Description: # Dropit - Simple Cross-Platform File Sharing
10
+
11
+ ## Introduction
12
+ Dropit simplifies the process of sharing files across multiple devices, including laptops and mobile phones, regardless of their operating system. Whether you're a developer working with multiple OS environments, or simply need to transfer files between devices, Dropit offers a straightforward solution.
13
+
14
+ ## Key Features
15
+ - **Cross-Platform Compatibility**: Share files seamlessly between any devices on the same network.
16
+ - **Easy to Use**: Just a single command is needed to start sharing files.
17
+ - **Optional Password Protection**: Enhance security with an optional password.
18
+
19
+ ## How to Use
20
+ To share files with Dropit, simply run the following command in your terminal:
21
+
22
+ ```bash
23
+ dropit [--password <password>]
24
+
25
+
26
+ Platform: UNKNOWN
27
+ Classifier: Development Status :: 3 - Alpha
28
+ Classifier: Intended Audience :: Developers
29
+ Classifier: License :: OSI Approved :: MIT License
30
+ Classifier: Programming Language :: Python :: 3
31
+ Classifier: Programming Language :: Python :: 3.7
32
+ Classifier: Programming Language :: Python :: 3.8
33
+ Classifier: Programming Language :: Python :: 3.9
34
+ Classifier: Framework :: Flask
35
+ Requires-Python: >=3.6
36
+ Description-Content-Type: text/markdown
dropit-0.1.0/README.md ADDED
@@ -0,0 +1,16 @@
1
+ # Dropit - Simple Cross-Platform File Sharing
2
+
3
+ ## Introduction
4
+ Dropit simplifies the process of sharing files across multiple devices, including laptops and mobile phones, regardless of their operating system. Whether you're a developer working with multiple OS environments, or simply need to transfer files between devices, Dropit offers a straightforward solution.
5
+
6
+ ## Key Features
7
+ - **Cross-Platform Compatibility**: Share files seamlessly between any devices on the same network.
8
+ - **Easy to Use**: Just a single command is needed to start sharing files.
9
+ - **Optional Password Protection**: Enhance security with an optional password.
10
+
11
+ ## How to Use
12
+ To share files with Dropit, simply run the following command in your terminal:
13
+
14
+ ```bash
15
+ dropit [--password <password>]
16
+
@@ -0,0 +1 @@
1
+ __version__ = "0.1.0"
@@ -0,0 +1,107 @@
1
+ #!/usr/bin/env python3
2
+ import os
3
+ import socket
4
+ import argparse
5
+ from functools import wraps
6
+ from flask import Flask, request, render_template, redirect, url_for, send_from_directory
7
+ from flask_basicauth import BasicAuth
8
+ import time
9
+
10
+ parser = argparse.ArgumentParser(description='File server with optional basic authentication.')
11
+ parser.add_argument('--password', help='Set the password for basic authentication.', default=None)
12
+ args = parser.parse_args()
13
+
14
+ app = Flask(__name__)
15
+ home_path = os.path.expanduser('~/sharex/')
16
+ app.config['UPLOAD_FOLDER'] = home_path
17
+ app.config['MAX_CONTENT_LENGTH'] = 1000 * 1024 * 1024
18
+
19
+
20
+ app.config['BASIC_AUTH_USERNAME'] = 'admin'
21
+ app.config['BASIC_AUTH_PASSWORD'] = args.password
22
+ app.config['BASIC_AUTH_FORCE'] = bool(args.password)
23
+
24
+ basic_auth = BasicAuth(app)
25
+
26
+ def optional_auth(f):
27
+ @wraps(f)
28
+ def decorated(*args, **kwargs):
29
+ if app.config['BASIC_AUTH_PASSWORD']:
30
+ return basic_auth.required(f)(*args, **kwargs)
31
+ return f(*args, **kwargs)
32
+ return decorated
33
+
34
+ @app.route('/', methods=['GET', 'POST'])
35
+ @optional_auth
36
+ def index():
37
+ if request.method == 'POST':
38
+ files = request.files.getlist('files')
39
+ for file in files:
40
+ if file:
41
+ file.save(os.path.join(app.config['UPLOAD_FOLDER'], file.filename))
42
+
43
+ files_info = []
44
+ for filename in os.listdir(app.config['UPLOAD_FOLDER']):
45
+ filepath = os.path.join(app.config['UPLOAD_FOLDER'], filename)
46
+ size_bytes = os.path.getsize(filepath)
47
+ size, unit = format_size(size_bytes)
48
+ filetype = filename.split('.')[-1] if '.' in filename else 'Unknown'
49
+ files_info.append({'name': filename, 'size': f"{size} {unit}", 'type': filetype})
50
+
51
+ return render_template('index.html', files=files_info)
52
+
53
+ def format_size(size_bytes):
54
+ """Helper function to format bytes to the most appropriate size unit."""
55
+ if size_bytes < 1024:
56
+ return size_bytes, 'B' # Bytes
57
+ elif size_bytes < 1024 ** 2:
58
+ return round(size_bytes / 1024, 2), 'KB' # Kilobytes
59
+ elif size_bytes < 1024 ** 3:
60
+ return round(size_bytes / 1024 ** 2, 2), 'MB' # Megabytes
61
+ else:
62
+ return round(size_bytes / 1024 ** 3, 2), 'GB' # Gigabytes
63
+
64
+ @app.route('/files/<filename>')
65
+ @optional_auth
66
+ def download_file(filename):
67
+ return send_from_directory(app.config['UPLOAD_FOLDER'], filename)
68
+
69
+ @app.route('/delete/<filename>')
70
+ @optional_auth
71
+ def delete_file(filename):
72
+ file_path = os.path.join(app.config['UPLOAD_FOLDER'], filename)
73
+ if os.path.exists(file_path):
74
+ os.remove(file_path)
75
+ return redirect(url_for('index'))
76
+
77
+ def get_ip():
78
+ s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
79
+ try:
80
+ s.connect(('8.8.8.8', 80))
81
+ IP = s.getsockname()[0]
82
+ finally:
83
+ s.close()
84
+ return IP
85
+
86
+
87
+ def print_colored_ip(ip, port):
88
+ os.system('cls' if os.name == 'nt' else 'clear')
89
+ colors = ["\033[1;32m", "\033[1;34m", "\033[1;31m", "\033[1;33m", "\033[1;35m", "\033[1;36m"]
90
+ for color in colors:
91
+ os.system('cls' if os.name == 'nt' else 'clear')
92
+ print(f"{color}The URL to enter on your other device connected to the same wifi network is: http://{ip}:{port}\033[0m")
93
+ time.sleep(0.5)
94
+ print("Starting the server. Please navigate to the URL shown above on your devices.")
95
+
96
+ def run_app():
97
+ """Function to run the Flask app."""
98
+ ip = get_ip()
99
+ port = 5001
100
+ if not os.path.exists(app.config['UPLOAD_FOLDER']):
101
+ os.makedirs(app.config['UPLOAD_FOLDER'])
102
+ print_colored_ip(ip, port)
103
+ app.run(host='0.0.0.0', port=port, debug=False)
104
+
105
+ if __name__ == '__main__':
106
+ run_app()
107
+
@@ -0,0 +1,80 @@
1
+ function updateFileList() {
2
+ var input = document.getElementById('file-input');
3
+ var output = document.getElementById('file-list');
4
+ var children = "<table style='width: 100%; border-collapse: collapse;'>";
5
+ children += "<tr><th>Name</th><th>Type</th><th>Size</th></tr>";
6
+
7
+ for (var i = 0; i < input.files.length; i++) {
8
+ let file = input.files.item(i);
9
+ let size = formatSize(file.size);
10
+ let type = file.type || 'Unknown';
11
+
12
+ children += `<tr>
13
+ <td>${file.name}</td>
14
+ <td>${type}</td>
15
+ <td>${size}</td>
16
+ </tr>`;
17
+ }
18
+ children += "</table>";
19
+ output.innerHTML = children;
20
+ }
21
+
22
+ function formatSize(bytes) {
23
+ if (bytes < 1024) return bytes + ' B';
24
+ else if (bytes < 1024 ** 2) return (bytes / 1024).toFixed(2) + ' KB';
25
+ else if (bytes < 1024 ** 3) return (bytes / 1024 ** 2).toFixed(2) + ' MB';
26
+ else return (bytes / 1024 ** 3).toFixed(2) + ' GB';
27
+ }
28
+
29
+
30
+
31
+
32
+ function sortTable(n, isSizeColumn = false) {
33
+ var table, rows, switching, i, x, y, shouldSwitch, dir, switchcount = 0;
34
+ table = document.getElementById("fileTable");
35
+ switching = true;
36
+ dir = "asc";
37
+
38
+ while (switching) {
39
+ switching = false;
40
+ rows = table.rows;
41
+
42
+ for (i = 1; i < (rows.length - 1); i++) {
43
+ shouldSwitch = false;
44
+ x = rows[i].getElementsByTagName("TD")[n];
45
+ y = rows[i + 1].getElementsByTagName("TD")[n];
46
+ var xVal = isSizeColumn ? convertToBytes(x.innerHTML) : x.innerHTML.toLowerCase();
47
+ var yVal = isSizeColumn ? convertToBytes(y.innerHTML) : y.innerHTML.toLowerCase();
48
+
49
+ if (dir == "asc") {
50
+ if (xVal > yVal) {
51
+ shouldSwitch = true;
52
+ break;
53
+ }
54
+ } else if (dir == "desc") {
55
+ if (xVal < yVal) {
56
+ shouldSwitch = true;
57
+ break;
58
+ }
59
+ }
60
+ }
61
+ if (shouldSwitch) {
62
+ rows[i].parentNode.insertBefore(rows[i + 1], rows[i]);
63
+ switching = true;
64
+ switchcount++;
65
+ } else {
66
+ if (switchcount == 0 && dir == "asc") {
67
+ dir = "desc";
68
+ switching = true;
69
+ }
70
+ }
71
+ }
72
+ }
73
+
74
+ function convertToBytes(sizeStr) {
75
+ const units = ["B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"];
76
+ const size = parseFloat(sizeStr);
77
+ const unit = sizeStr.replace(/[.\d\s]/g, '').toUpperCase();
78
+ const exponent = units.indexOf(unit);
79
+ return size * Math.pow(1024, exponent);
80
+ }
@@ -0,0 +1,134 @@
1
+ body {
2
+ font-family: 'Roboto', Arial, sans-serif;
3
+ background-color: #f4f4f4;
4
+ color: #333;
5
+ margin: 0;
6
+ padding: 20px;
7
+ overflow-x: auto;
8
+ }
9
+
10
+ header, form, table {
11
+ background-color: #ffffff;
12
+ padding: 20px;
13
+ border-radius: 8px;
14
+ box-shadow: 0 4px 6px rgba(0,0,0,0.1);
15
+ margin-bottom: 20px;
16
+ }
17
+
18
+ input[type="file"], button, .dropdown .dropbtn, .dropdown-content a {
19
+ width: 100%;
20
+ box-sizing: border-box;
21
+ }
22
+
23
+ form {
24
+ display: flex;
25
+ flex-direction: column;
26
+ align-items: center;
27
+ }
28
+
29
+ label, .dropdown-content a {
30
+ font-weight: bold;
31
+ color: #5c6bc0;
32
+ }
33
+
34
+
35
+ input[type="file"] {
36
+ background: transparent;
37
+ border: 2px solid #5c6bc0;
38
+ border-radius: 4px;
39
+ padding: 10px;
40
+ color: #333;
41
+ }
42
+
43
+
44
+ button, .dropbtn {
45
+ background-color: #5c6bc0;
46
+ color: white;
47
+ border: none;
48
+ padding: 10px 15px;
49
+ font-size: 16px;
50
+ cursor: pointer;
51
+ border-radius: 4px;
52
+ transition: background-color 0.3s ease;
53
+ }
54
+
55
+ button:hover, .dropdown:hover .dropbtn {
56
+ background-color: #3949ab;
57
+ }
58
+
59
+
60
+ table {
61
+ width: 100%;
62
+ border-collapse: collapse;
63
+ table-layout: fixed;
64
+ }
65
+
66
+ th, td {
67
+ padding: 10px;
68
+ text-align: left;
69
+ overflow: hidden;
70
+ text-overflow: ellipsis;
71
+ white-space: nowrap;
72
+ }
73
+
74
+ th {
75
+ background-color: #5c6bc0;
76
+ color: white;
77
+ }
78
+
79
+ tr:nth-child(even) {
80
+ background-color: #e8eaf6;
81
+ }
82
+
83
+ .dropdown-content a {
84
+ background-color: #5c6bc0;
85
+ color: white;
86
+ padding: 8px 16px;
87
+ margin: 5px 0;
88
+ display: block;
89
+ text-align: center;
90
+ border-radius: 4px;
91
+ box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
92
+ }
93
+
94
+ .dropdown-content a:hover {
95
+ background-color: #3949ab;
96
+ box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
97
+ }
98
+
99
+
100
+ .dropdown {
101
+ position: relative;
102
+ }
103
+
104
+
105
+ .dropdown-content {
106
+ padding: 5px;
107
+ box-shadow: 0 8px 16px rgba(0, 0, 0, 0.15);
108
+ border-radius: 8px;
109
+ }
110
+
111
+ #file-list table {
112
+ width: 100%;
113
+ border-collapse: collapse;
114
+ margin-top: 10px;
115
+ background-color: #ffffff;
116
+ padding: 10px;
117
+ border-radius: 8px;
118
+ box-shadow: 0 4px 6px rgba(0,0,0,0.1);
119
+ }
120
+
121
+ #file-list th, #file-list td {
122
+ padding: 10px;
123
+ text-align: left;
124
+ border-bottom: 1px solid #ddd;
125
+ }
126
+
127
+ #file-list th {
128
+ background-color: #5c6bc0;
129
+ color: white;
130
+ }
131
+
132
+ #file-list tr:nth-child(even) {
133
+ background-color: #e8eaf6;
134
+ }
@@ -0,0 +1,53 @@
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">
6
+ <title>File Sharing Service</title>
7
+ <link rel="stylesheet" href="{{ url_for('static', filename='styles.css') }}">
8
+ <script src="{{ url_for('static', filename='scripts.js') }}"></script>
9
+ </head>
10
+
11
+ <header>
12
+ <h1>Dropit- Easy Local File Sharing</h1>
13
+ <p>Quickly and securely share files across devices on the same network.</p>
14
+ </header>
15
+
16
+ <body>
17
+ <h1>Sharex</h1>
18
+ <form method="POST" action="/" enctype="multipart/form-data">
19
+ <label for="file-input">Choose Files</label>
20
+ <input id="file-input" type="file" name="files" multiple onchange="updateFileList()">
21
+ <ul id="file-list"></ul>
22
+ <button type="submit">Upload</button>
23
+ </form>
24
+ <h2>Uploaded Files</h2>
25
+ <table id="fileTable">
26
+ <thead>
27
+ <tr>
28
+ <th onclick="sortTable(0)">File Name</th>
29
+ <th onclick="sortTable(1)">Type</th>
30
+ <th onclick="sortTable(2, true)">Size</th> <!-- Note the 'true' to handle size conversion -->
31
+ <th>Actions</th>
32
+ </tr>
33
+ </thead>
34
+ <tbody>
35
+ {% for file in files %}
36
+ <tr>
37
+ <td>{{ file.name }}</td>
38
+ <td>{{ file.type }}</td>
39
+ <td>{{ file.size }}</td>
40
+ <td>
41
+ <div class="dropdown">
42
+ <div class="dropdown-content">
43
+ <a href="{{ url_for('download_file', filename=file.name) }}">Download</a>
44
+ <a href="{{ url_for('delete_file', filename=file.name) }}">Delete</a>
45
+ </div>
46
+ </div>
47
+ </td>
48
+ </tr>
49
+ {% endfor %}
50
+ </tbody>
51
+ </table>
52
+ </body>
53
+ </html>
@@ -0,0 +1,36 @@
1
+ Metadata-Version: 2.1
2
+ Name: dropit
3
+ Version: 0.1.0
4
+ Summary: A Flask-based command line file sharing application.
5
+ Home-page: https://github.com/1darshanpatil/dropit
6
+ Author: Darshan P.
7
+ Author-email: drshnp@outlook.com
8
+ License: UNKNOWN
9
+ Description: # Dropit - Simple Cross-Platform File Sharing
10
+
11
+ ## Introduction
12
+ Dropit simplifies the process of sharing files across multiple devices, including laptops and mobile phones, regardless of their operating system. Whether you're a developer working with multiple OS environments, or simply need to transfer files between devices, Dropit offers a straightforward solution.
13
+
14
+ ## Key Features
15
+ - **Cross-Platform Compatibility**: Share files seamlessly between any devices on the same network.
16
+ - **Easy to Use**: Just a single command is needed to start sharing files.
17
+ - **Optional Password Protection**: Enhance security with an optional password.
18
+
19
+ ## How to Use
20
+ To share files with Dropit, simply run the following command in your terminal:
21
+
22
+ ```bash
23
+ dropit [--password <password>]
24
+
25
+
26
+ Platform: UNKNOWN
27
+ Classifier: Development Status :: 3 - Alpha
28
+ Classifier: Intended Audience :: Developers
29
+ Classifier: License :: OSI Approved :: MIT License
30
+ Classifier: Programming Language :: Python :: 3
31
+ Classifier: Programming Language :: Python :: 3.7
32
+ Classifier: Programming Language :: Python :: 3.8
33
+ Classifier: Programming Language :: Python :: 3.9
34
+ Classifier: Framework :: Flask
35
+ Requires-Python: >=3.6
36
+ Description-Content-Type: text/markdown
@@ -0,0 +1,15 @@
1
+ LICENSE
2
+ MANIFEST.in
3
+ README.md
4
+ setup.py
5
+ dropit/__init__.py
6
+ dropit/main.py
7
+ dropit.egg-info/PKG-INFO
8
+ dropit.egg-info/SOURCES.txt
9
+ dropit.egg-info/dependency_links.txt
10
+ dropit.egg-info/entry_points.txt
11
+ dropit.egg-info/requires.txt
12
+ dropit.egg-info/top_level.txt
13
+ dropit/static/scripts.js
14
+ dropit/static/styles.css
15
+ dropit/templates/index.html
@@ -0,0 +1,3 @@
1
+ [console_scripts]
2
+ dropit = dropit.main:run_app
3
+
@@ -0,0 +1,2 @@
1
+ Flask-BasicAuth==0.2.0
2
+ Flask==3.0.3
@@ -0,0 +1 @@
1
+ dropit
dropit-0.1.0/setup.cfg ADDED
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
dropit-0.1.0/setup.py ADDED
@@ -0,0 +1,41 @@
1
+ from setuptools import setup, find_packages
2
+ import os
3
+ import sys
4
+
5
+ package_dir = os.path.abspath(os.path.dirname(__file__))
6
+ sys.path.insert(0, os.path.join(package_dir, 'sharex'))
7
+
8
+ from dropit import __version__
9
+
10
+ with open(os.path.join(package_dir, 'requirements.txt')) as f:
11
+ required = f.read().splitlines()
12
+
13
+ setup(
14
+ name='dropit',
15
+ version=__version__,
16
+ author='Darshan P.',
17
+ author_email='drshnp@outlook.com',
18
+ description='A Flask-based command line file sharing application.',
19
+ long_description=open(os.path.join(package_dir, 'README.md')).read(),
20
+ long_description_content_type='text/markdown',
21
+ url='https://github.com/1darshanpatil/dropit',
22
+ packages=find_packages(),
23
+ include_package_data=True,
24
+ install_requires=required,
25
+ entry_points={
26
+ 'console_scripts': [
27
+ 'dropit=dropit.main:run_app'
28
+ ]
29
+ },
30
+ classifiers=[
31
+ 'Development Status :: 3 - Alpha',
32
+ 'Intended Audience :: Developers',
33
+ 'License :: OSI Approved :: MIT License',
34
+ 'Programming Language :: Python :: 3',
35
+ 'Programming Language :: Python :: 3.7',
36
+ 'Programming Language :: Python :: 3.8',
37
+ 'Programming Language :: Python :: 3.9',
38
+ 'Framework :: Flask',
39
+ ],
40
+ python_requires='>=3.6',
41
+ )