Compare commits
7 Commits
864b2161b1
...
f2594c2adf
Author | SHA1 | Date |
---|---|---|
Sebastian Lohff | f2594c2adf | |
Sebastian Lohff | 95852ba11d | |
Sebastian Lohff | 14771695c4 | |
Sebastian Lohff | 5c78991bc8 | |
Sebastian Lohff | ef41f65996 | |
Sebastian Lohff | 19c1b000a4 | |
Sebastian Lohff | 3d46950d6c |
13
ChangeLog
13
ChangeLog
|
@ -1,6 +1,19 @@
|
|||
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
|
||||
-----------------
|
||||
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
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
|
||||
```
|
|
@ -1,4 +1,4 @@
|
|||
.TH SERVEFILE 1 "November 2015" "servefile 0.4.4" "User Commands"
|
||||
.TH SERVEFILE 1 "September 2020" "servefile 0.5.0" "User Commands"
|
||||
|
||||
.SH NAME
|
||||
servefile \- small HTTP-Server for temporary file transfer
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
from . import servefile
|
||||
|
||||
servefile.main()
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
from __future__ import print_function
|
||||
|
||||
__version__ = '0.4.4'
|
||||
__version__ = '0.5.0'
|
||||
|
||||
import argparse
|
||||
import base64
|
||||
|
@ -1109,7 +1109,7 @@ class AuthenticationHandler():
|
|||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description='Serve a single file via HTTP.')
|
||||
parser = argparse.ArgumentParser(prog='servefile', description='Serve a single file via HTTP.')
|
||||
parser.add_argument('--version', action='version', version='%(prog)s ' + __version__)
|
||||
parser.add_argument('target', metavar='file/directory', type=str)
|
||||
parser.add_argument('-p', '--port', type=int, default=8080, \
|
84
setup.py
84
setup.py
|
@ -1,42 +1,52 @@
|
|||
#!/usr/bin/python
|
||||
#!/usr/bin/env python
|
||||
|
||||
from setuptools import setup
|
||||
|
||||
with open("README.md") as f:
|
||||
long_description = f.read()
|
||||
|
||||
setup(
|
||||
name='servefile',
|
||||
description='Serve files from shell via a small HTTP server',
|
||||
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.',
|
||||
platforms='posix',
|
||||
version='0.4.4',
|
||||
license='GPLv3 or later',
|
||||
url='https://seba-geek.de/stuff/servefile/',
|
||||
author='Sebastian Lohff',
|
||||
author_email='seba@someserver.de',
|
||||
install_requires=['pyopenssl'],
|
||||
tests_require=[
|
||||
'pathlib2; python_version<"3"',
|
||||
'pytest',
|
||||
'requests',
|
||||
],
|
||||
scripts=['servefile'],
|
||||
classifiers=[
|
||||
'Development Status :: 5 - Production/Stable',
|
||||
'Environment :: Console',
|
||||
'Intended Audience :: End Users/Desktop',
|
||||
'License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)',
|
||||
'Natural Language :: English',
|
||||
'Programming Language :: Python',
|
||||
'Programming Language :: Python :: 2',
|
||||
'Programming Language :: Python :: 2.7',
|
||||
'Programming Language :: Python :: 3',
|
||||
'Programming Language :: Python :: 3.6',
|
||||
'Programming Language :: Python :: 3.7',
|
||||
'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',
|
||||
],
|
||||
name='servefile',
|
||||
description='Serve files from shell via a small HTTP server',
|
||||
long_description=long_description,
|
||||
long_description_content_type='text/markdown',
|
||||
platforms='posix',
|
||||
version='0.5.0',
|
||||
license='GPLv3 or later',
|
||||
url='https://github.com/sebageek/servefile/',
|
||||
author='Sebastian Lohff',
|
||||
author_email='seba@someserver.de',
|
||||
install_requires=['pyopenssl'],
|
||||
tests_require=[
|
||||
'pathlib2; python_version<"3"',
|
||||
'pytest',
|
||||
'requests',
|
||||
],
|
||||
packages=["servefile"],
|
||||
entry_points={
|
||||
"console_scripts": [
|
||||
"servefile = servefile.servefile:main",
|
||||
],
|
||||
},
|
||||
classifiers=[
|
||||
'Development Status :: 5 - Production/Stable',
|
||||
'Environment :: Console',
|
||||
'Intended Audience :: End Users/Desktop',
|
||||
'License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)',
|
||||
'Natural Language :: English',
|
||||
'Programming Language :: Python',
|
||||
'Programming Language :: Python :: 2',
|
||||
'Programming Language :: Python :: 2.7',
|
||||
'Programming Language :: Python :: 3',
|
||||
'Programming Language :: Python :: 3.5',
|
||||
'Programming Language :: Python :: 3.6',
|
||||
'Programming Language :: Python :: 3.7',
|
||||
'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',
|
||||
],
|
||||
)
|
||||
|
|
|
@ -27,9 +27,15 @@ def run_servefile():
|
|||
def _run_servefile(args, **kwargs):
|
||||
if not isinstance(args, list):
|
||||
args = [args]
|
||||
print("running with args", args)
|
||||
servefile_path = str(Path(__file__).parent.parent / 'servefile')
|
||||
p = subprocess.Popen([sys.executable, servefile_path] + args, **kwargs)
|
||||
if kwargs.pop('standalone', None):
|
||||
# directly call servefile.py
|
||||
servefile_path = [str(Path(__file__).parent.parent / 'servefile' / 'servefile.py')]
|
||||
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))
|
||||
instances.append(p)
|
||||
|
||||
|
@ -85,14 +91,29 @@ def check_download(expected_data=None, path='/', fname=None, status_code=200, **
|
|||
return r # for additional tests
|
||||
|
||||
|
||||
def test_version(run_servefile):
|
||||
def _test_version(run_servefile, standalone):
|
||||
# we expect the version on stdout (python3.4+) or stderr(python2.6-3.3)
|
||||
s = run_servefile('--version', stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
||||
s = run_servefile('--version', standalone=standalone, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
||||
s.wait()
|
||||
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
|
||||
assert version == 'servefile 0.4.4'
|
||||
assert version == 'servefile 0.5.0'
|
||||
|
||||
|
||||
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):
|
||||
|
@ -325,6 +346,7 @@ def test_https(run_servefile, datadir):
|
|||
urllib3.disable_warnings()
|
||||
check_download(data, protocol='https', verify=False)
|
||||
|
||||
|
||||
def test_https_big_download(run_servefile, datadir):
|
||||
# test with about 10 mb of data
|
||||
data = "x" * (10 * 1024 ** 2)
|
||||
|
|
Loading…
Reference in New Issue