Compare commits

..

No commits in common. "f2594c2adf530ef330ebaf1ee54e4b3c6c1b713c" and "864b2161b16e432c8ba19db1914809e080d793af" have entirely different histories.

8 changed files with 46 additions and 127 deletions

View File

@ -1,19 +1,6 @@
servefile changelog servefile changelog
=================== ===================
2020-10-29 v0.5.0
-----------------
0.5.0 released
* python3 support
* test suite
* fixed an endless redirect loop when serving ../
* added sorting for list view
* added lzma/xz as compression method
2015-11-10 v0.4.4 2015-11-10 v0.4.4
----------------- -----------------

View File

@ -1,33 +0,0 @@
Servefile
=========
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). Besides that
it also supports uploads, SSL, HTTP basic auth and directory listings.
Features:
* serve single file
* serve a directory with directory index
* file upload via webinterface
* HTTPS with on the fly generated self signed SSL certificates
* HTTP basic authentication
* serving files/directories as on request generated tar files
Install
-------
Via pip
```shell
pip install servefile
```
After installation either execute `servefile --help` or `python -m servefile --help`
Standalone:
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.
```shell
$ wget https://raw.githubusercontent.com/sebageek/servefile/master/servefile/servefile.py -O servefile
$ chmod +x servefile
$ ./servefile --help
```

View File

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

View File

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

View File

View File

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

View File

@ -1,52 +1,42 @@
#!/usr/bin/env python #!/usr/bin/python
from setuptools import setup from setuptools import setup
with open("README.md") as f:
long_description = f.read()
setup( setup(
name='servefile', name='servefile',
description='Serve files from shell via a small HTTP server', description='Serve files from shell via a small HTTP server',
long_description=long_description, 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.',
long_description_content_type='text/markdown', platforms='posix',
platforms='posix', version='0.4.4',
version='0.5.0', license='GPLv3 or later',
license='GPLv3 or later', url='https://seba-geek.de/stuff/servefile/',
url='https://github.com/sebageek/servefile/', author='Sebastian Lohff',
author='Sebastian Lohff', author_email='seba@someserver.de',
author_email='seba@someserver.de', install_requires=['pyopenssl'],
install_requires=['pyopenssl'], tests_require=[
tests_require=[ 'pathlib2; python_version<"3"',
'pathlib2; python_version<"3"', 'pytest',
'pytest', 'requests',
'requests', ],
], scripts=['servefile'],
packages=["servefile"], classifiers=[
entry_points={ 'Development Status :: 5 - Production/Stable',
"console_scripts": [ 'Environment :: Console',
"servefile = servefile.servefile:main", 'Intended Audience :: End Users/Desktop',
], 'License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)',
}, 'Natural Language :: English',
classifiers=[ 'Programming Language :: Python',
'Development Status :: 5 - Production/Stable', 'Programming Language :: Python :: 2',
'Environment :: Console', 'Programming Language :: Python :: 2.7',
'Intended Audience :: End Users/Desktop', 'Programming Language :: Python :: 3',
'License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)', 'Programming Language :: Python :: 3.6',
'Natural Language :: English', 'Programming Language :: Python :: 3.7',
'Programming Language :: Python', 'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 2', 'Topic :: Communications',
'Programming Language :: Python :: 2.7', 'Topic :: Communications :: File Sharing',
'Programming Language :: Python :: 3', 'Topic :: Internet',
'Programming Language :: Python :: 3.5', 'Topic :: Internet :: WWW/HTTP',
'Programming Language :: Python :: 3.6', 'Topic :: Internet :: WWW/HTTP :: HTTP Servers',
'Programming Language :: Python :: 3.7', 'Topic :: Utilities',
'Programming Language :: Python :: 3.8', ],
'Topic :: Communications',
'Topic :: Communications :: File Sharing',
'Topic :: Internet',
'Topic :: Internet :: WWW/HTTP',
'Topic :: Internet :: WWW/HTTP :: HTTP Servers',
'Topic :: Utilities',
],
) )

View File

@ -27,15 +27,9 @@ def run_servefile():
def _run_servefile(args, **kwargs): def _run_servefile(args, **kwargs):
if not isinstance(args, list): if not isinstance(args, list):
args = [args] args = [args]
if kwargs.pop('standalone', None): print("running with args", args)
# directly call servefile.py servefile_path = str(Path(__file__).parent.parent / 'servefile')
servefile_path = [str(Path(__file__).parent.parent / 'servefile' / 'servefile.py')] p = subprocess.Popen([sys.executable, servefile_path] + args, **kwargs)
else:
# call servefile as python module
servefile_path = ['-m', 'servefile']
print("running {} with args {}".format(", ".join(servefile_path), args))
p = subprocess.Popen([sys.executable] + servefile_path + args, **kwargs)
time.sleep(kwargs.get('timeout', 0.3)) time.sleep(kwargs.get('timeout', 0.3))
instances.append(p) instances.append(p)
@ -91,29 +85,14 @@ def check_download(expected_data=None, path='/', fname=None, status_code=200, **
return r # for additional tests return r # for additional tests
def _test_version(run_servefile, standalone): def test_version(run_servefile):
# we expect the version on stdout (python3.4+) or stderr(python2.6-3.3) # we expect the version on stdout (python3.4+) or stderr(python2.6-3.3)
s = run_servefile('--version', standalone=standalone, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) s = run_servefile('--version', stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
s.wait() s.wait()
version = s.stdout.readline().decode().strip() version = s.stdout.readline().decode().strip()
# python2 is deprecated, but we still want our tests to run for it
# CryptographyDeprecationWarnings get in the way for this
if 'CryptographyDeprecationWarning' in version:
s.stdout.readline() # ignore "from x import y" line
version = s.stdout.readline().decode().strip()
# hardcode version as string until servefile is a module # hardcode version as string until servefile is a module
assert version == 'servefile 0.5.0' assert version == 'servefile 0.4.4'
def test_version(run_servefile):
_test_version(run_servefile, standalone=False)
def test_version_standalone(run_servefile):
# test if servefile also works by calling servefile.py directly
_test_version(run_servefile, standalone=True)
def test_correct_headers(run_servefile, datadir): def test_correct_headers(run_servefile, datadir):
@ -346,7 +325,6 @@ def test_https(run_servefile, datadir):
urllib3.disable_warnings() urllib3.disable_warnings()
check_download(data, protocol='https', verify=False) check_download(data, protocol='https', verify=False)
def test_https_big_download(run_servefile, datadir): def test_https_big_download(run_servefile, datadir):
# test with about 10 mb of data # test with about 10 mb of data
data = "x" * (10 * 1024 ** 2) data = "x" * (10 * 1024 ** 2)