7 Commits

Author SHA1 Message Date
  Sebastian Lohff f2594c2adf Release v0.5.0 1 year ago
  Sebastian Lohff 95852ba11d Change project url to GitHub 1 year ago
  Sebastian Lohff 14771695c4 Add README.md 1 year ago
  Sebastian Lohff 5c78991bc8 Advertise python3.5 support 1 year ago
  Sebastian Lohff ef41f65996 Workaround for python2 deprecation in tests 1 year ago
  Sebastian Lohff 19c1b000a4 Make servefile a python package 1 year ago
  Sebastian Lohff 3d46950d6c Use spaces instead of tabs for setup.py 1 year ago
8 changed files with 127 additions and 46 deletions
  1. 13
    0
      ChangeLog
  2. 33
    0
      README.md
  3. 1
    1
      servefile.1
  4. 0
    0
      servefile/__init__.py
  5. 3
    0
      servefile/__main__.py
  6. 2
    2
      servefile/servefile.py
  7. 47
    37
      setup.py
  8. 28
    6
      tests/test_servefile.py

+ 13
- 0
ChangeLog View File

@@ -1,6 +1,19 @@
1 1
 servefile changelog
2 2
 ===================
3 3
 
4
+
5
+2020-10-29 v0.5.0
6
+-----------------
7
+
8
+	0.5.0 released
9
+
10
+	* python3 support
11
+	* test suite
12
+	* fixed an endless redirect loop when serving ../
13
+	* added sorting for list view
14
+	* added lzma/xz as compression method
15
+
16
+
4 17
 2015-11-10 v0.4.4
5 18
 -----------------
6 19
 

+ 33
- 0
README.md View File

@@ -0,0 +1,33 @@
1
+Servefile
2
+=========
3
+
4
+Serve files from shell via a small HTTP server. The server redirects all HTTP
5
+requests to the file, so only IP and port must be given to another user to
6
+access the file. Its main purpose is to quickly send a file to users in your
7
+local network, independent of their current setup (OS/software). Besides that
8
+it also supports uploads, SSL, HTTP basic auth and directory listings.
9
+
10
+Features:
11
+ * serve single file
12
+ * serve a directory with directory index
13
+ * file upload via webinterface
14
+ * HTTPS with on the fly generated self signed SSL certificates
15
+ * HTTP basic authentication
16
+ * serving files/directories as on request generated tar files
17
+
18
+Install
19
+-------
20
+
21
+Via pip
22
+```shell
23
+pip install servefile
24
+```
25
+After installation either execute `servefile --help` or `python -m servefile --help`
26
+
27
+Standalone:
28
+If you don't have pip available just copy `servefile/servefile.py` onto the target machine, make it executable and you are ready to go.
29
+```shell
30
+$ wget https://raw.githubusercontent.com/sebageek/servefile/master/servefile/servefile.py -O servefile
31
+$ chmod +x servefile
32
+$ ./servefile --help
33
+```

+ 1
- 1
servefile.1 View File

@@ -1,4 +1,4 @@
1
-.TH SERVEFILE 1 "November 2015" "servefile 0.4.4" "User Commands"
1
+.TH SERVEFILE 1 "September 2020" "servefile 0.5.0" "User Commands"
2 2
 
3 3
 .SH NAME
4 4
 servefile \- small HTTP-Server for temporary file transfer

+ 0
- 0
servefile/__init__.py View File


+ 3
- 0
servefile/__main__.py View File

@@ -0,0 +1,3 @@
1
+from . import servefile
2
+
3
+servefile.main()

servefile → servefile/servefile.py View File

@@ -7,7 +7,7 @@
7 7
 
8 8
 from __future__ import print_function
9 9
 
10
-__version__ = '0.4.4'
10
+__version__ = '0.5.0'
11 11
 
12 12
 import argparse
13 13
 import base64
@@ -1109,7 +1109,7 @@ class AuthenticationHandler():
1109 1109
 
1110 1110
 
1111 1111
 def main():
1112
-	parser = argparse.ArgumentParser(description='Serve a single file via HTTP.')
1112
+	parser = argparse.ArgumentParser(prog='servefile', description='Serve a single file via HTTP.')
1113 1113
 	parser.add_argument('--version', action='version', version='%(prog)s ' + __version__)
1114 1114
 	parser.add_argument('target', metavar='file/directory', type=str)
1115 1115
 	parser.add_argument('-p', '--port', type=int, default=8080, \

+ 47
- 37
setup.py View File

@@ -1,42 +1,52 @@
1
-#!/usr/bin/python
1
+#!/usr/bin/env python
2 2
 
3 3
 from setuptools import setup
4 4
 
5
+with open("README.md") as f:
6
+    long_description = f.read()
7
+
5 8
 setup(
6
-	name='servefile',
7
-	description='Serve files from shell via a small HTTP server',
8
-	long_description='Serve files from shell via a small HTTP server. The server redirects all HTTP requests to the file, so only IP and port must be given to another user to access the file. Its main purpose is to quickly send a file to users in your local network, independent of their current setup (OS/software). Beneath that it also supports uploads, SSL, HTTP basic auth and directory listings.',
9
-	platforms='posix',
10
-	version='0.4.4',
11
-	license='GPLv3 or later',
12
-	url='https://seba-geek.de/stuff/servefile/',
13
-	author='Sebastian Lohff',
14
-	author_email='seba@someserver.de',
15
-	install_requires=['pyopenssl'],
16
-	tests_require=[
17
-		'pathlib2; python_version<"3"',
18
-		'pytest',
19
-		'requests',
20
-	],
21
-	scripts=['servefile'],
22
-	classifiers=[
23
-		'Development Status :: 5 - Production/Stable',
24
-		'Environment :: Console',
25
-		'Intended Audience :: End Users/Desktop',
26
-		'License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)',
27
-		'Natural Language :: English',
28
-		'Programming Language :: Python',
29
-		'Programming Language :: Python :: 2',
30
-		'Programming Language :: Python :: 2.7',
31
-		'Programming Language :: Python :: 3',
32
-		'Programming Language :: Python :: 3.6',
33
-		'Programming Language :: Python :: 3.7',
34
-		'Programming Language :: Python :: 3.8',
35
-		'Topic :: Communications',
36
-		'Topic :: Communications :: File Sharing',
37
-		'Topic :: Internet',
38
-		'Topic :: Internet :: WWW/HTTP',
39
-		'Topic :: Internet :: WWW/HTTP :: HTTP Servers',
40
-		'Topic :: Utilities',
41
-	],
9
+    name='servefile',
10
+    description='Serve files from shell via a small HTTP server',
11
+    long_description=long_description,
12
+    long_description_content_type='text/markdown',
13
+    platforms='posix',
14
+    version='0.5.0',
15
+    license='GPLv3 or later',
16
+    url='https://github.com/sebageek/servefile/',
17
+    author='Sebastian Lohff',
18
+    author_email='seba@someserver.de',
19
+    install_requires=['pyopenssl'],
20
+    tests_require=[
21
+        'pathlib2; python_version<"3"',
22
+        'pytest',
23
+        'requests',
24
+    ],
25
+    packages=["servefile"],
26
+    entry_points={
27
+        "console_scripts": [
28
+            "servefile = servefile.servefile:main",
29
+        ],
30
+    },
31
+    classifiers=[
32
+        'Development Status :: 5 - Production/Stable',
33
+        'Environment :: Console',
34
+        'Intended Audience :: End Users/Desktop',
35
+        'License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)',
36
+        'Natural Language :: English',
37
+        'Programming Language :: Python',
38
+        'Programming Language :: Python :: 2',
39
+        'Programming Language :: Python :: 2.7',
40
+        'Programming Language :: Python :: 3',
41
+        'Programming Language :: Python :: 3.5',
42
+        'Programming Language :: Python :: 3.6',
43
+        'Programming Language :: Python :: 3.7',
44
+        'Programming Language :: Python :: 3.8',
45
+        'Topic :: Communications',
46
+        'Topic :: Communications :: File Sharing',
47
+        'Topic :: Internet',
48
+        'Topic :: Internet :: WWW/HTTP',
49
+        'Topic :: Internet :: WWW/HTTP :: HTTP Servers',
50
+        'Topic :: Utilities',
51
+    ],
42 52
 )

+ 28
- 6
tests/test_servefile.py View File

@@ -27,9 +27,15 @@ def run_servefile():
27 27
     def _run_servefile(args, **kwargs):
28 28
         if not isinstance(args, list):
29 29
             args = [args]
30
-        print("running with args", args)
31
-        servefile_path = str(Path(__file__).parent.parent / 'servefile')
32
-        p = subprocess.Popen([sys.executable, servefile_path] + args, **kwargs)
30
+        if kwargs.pop('standalone', None):
31
+            # directly call servefile.py
32
+            servefile_path = [str(Path(__file__).parent.parent / 'servefile' / 'servefile.py')]
33
+        else:
34
+            # call servefile as python module
35
+            servefile_path = ['-m', 'servefile']
36
+
37
+        print("running {} with args {}".format(", ".join(servefile_path), args))
38
+        p = subprocess.Popen([sys.executable] + servefile_path + args, **kwargs)
33 39
         time.sleep(kwargs.get('timeout', 0.3))
34 40
         instances.append(p)
35 41
 
@@ -85,14 +91,29 @@ def check_download(expected_data=None, path='/', fname=None, status_code=200, **
85 91
     return r  # for additional tests
86 92
 
87 93
 
88
-def test_version(run_servefile):
94
+def _test_version(run_servefile, standalone):
89 95
     # we expect the version on stdout (python3.4+) or stderr(python2.6-3.3)
90
-    s = run_servefile('--version', stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
96
+    s = run_servefile('--version', standalone=standalone, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
91 97
     s.wait()
92 98
     version = s.stdout.readline().decode().strip()
93 99
 
100
+    # python2 is deprecated, but we still want our tests to run for it
101
+    # CryptographyDeprecationWarnings get in the way for this
102
+    if 'CryptographyDeprecationWarning' in version:
103
+        s.stdout.readline()  # ignore "from x import y" line
104
+        version = s.stdout.readline().decode().strip()
105
+
94 106
     # hardcode version as string until servefile is a module
95
-    assert version == 'servefile 0.4.4'
107
+    assert version == 'servefile 0.5.0'
108
+
109
+
110
+def test_version(run_servefile):
111
+    _test_version(run_servefile, standalone=False)
112
+
113
+
114
+def test_version_standalone(run_servefile):
115
+    # test if servefile also works by calling servefile.py directly
116
+    _test_version(run_servefile, standalone=True)
96 117
 
97 118
 
98 119
 def test_correct_headers(run_servefile, datadir):
@@ -325,6 +346,7 @@ def test_https(run_servefile, datadir):
325 346
     urllib3.disable_warnings()
326 347
     check_download(data, protocol='https', verify=False)
327 348
 
349
+
328 350
 def test_https_big_download(run_servefile, datadir):
329 351
     # test with about 10 mb of data
330 352
     data = "x" * (10 * 1024 ** 2)

Loading…
Cancel
Save