Python module designed to streamline interactions with filebrowser
Project description
Deployments
PyFileBrowser
Introducing pyfilebrowser
, a Python library designed to streamline interactions with filebrowser
This wrapper simplifies integration and automation tasks, enabling seamless interaction with your local file system via filebrowser's web interface.
All the required configuration, settings, and user profiles are loaded using .env
files. This provides a more centralized
way of handling the configuration and initialization.
pyfilebrowser
automatically downloads the system specific executable during startup.
Download custom-built executables
Additionally, custom source (to download binaries) can be configured by specifying the environment variables,
GIT_OWNER
and GIT_REPO
For this custom source feature to work, the executable should be uploaded to releases as assets,
and follow the naming convention below.
asset naming convention:
${operating system}-{architecture}-filebrowser-{extension}
example:darwin-amd64-filebrowser.tar.gz
Kick Off
Install
python -m pip install pyfilebrowser
Initiate
import pyfilebrowser
if __name__ == '__main__':
browser = pyfilebrowser.FileBrowser()
# browser.proxy = True # [Optional] Enables proxy server to run in parallel
browser.start()
Environment Variables
Env vars can either be loaded from .env
files or directly passed during object init.
.env
files
proxy server
.proxy.env
- Loads the proxy server's configuration.
host
- Hostname/IP for the proxy server. Defaults tosocket.gethostbyname('localhost')
port
- Port number for the proxy server. Defaults to8000
workers
- Number of workers used to run the proxy server. Defaults to1
debug
- Boolean flag to enable debug level logging. Defaults toFalse
origins
- Origins to allow connections through proxy server. Defaults tohost
***public_ip
- Boolean flag to include public IP address of the host. Defaults toFalse
private_ip
- Boolean flag to include private IP address of the host. Defaults toFalse
error_page
- Error page to serve when filebrowser API is down. Defaults to error.htmlrate_limit
-Dict/List[Dict]
with the rate limit for the proxy server. Defaults toNone
filebrowser configuration
.config.env
- Loads the server's default configuration. Reference: config
filebrowser user profiles
.user*.env
- Loads each user's profile specific configuration. Reference: users
Multiple user profiles can be loaded using .user1.env
, .user2.env
and so on.
User profile's permissions are automatically set based on the admin
flag set in the env-var authentication
Refer samples directory for sample .env
files. For nested configuration settings, refer the runbook
Any configuration changes made in the UI will be lost, unless backed up manually.
Changes should always go through the.env
files.
Object level instantiation is also possible, but not recommended
from pyfilebrowser import FileBrowser
if __name__ == '__main__':
file_browser = FileBrowser(
user_profiles=[
{"authentication": {"username": "admin", "password": "admin", "admin": True}},
{"authentication": {"username": "user123", "password": "pwd456", "admin": False}}
]
)
file_browser.start()
Object level instantiation might be complex for configuration settings. So it is better to use
.env
files instead.
Proxy Server
pyfilebrowser
allows you to run a proxy server in parallel, which helps the user with much more logging information,
and secured connections.
The proxy server is pretty restrictive in nature, and doesn't like connections from outside the grid.
While CORS may solve the purpose at the webpage level, pyfilebrowser
's inbuilt proxy restricts connections
from any origin regardless of the tool used to connect (PostMan, curl, wget etc.)
Due to this behavior, please make sure to specify ALL the origins that are supposed to be allowed (including but not limited to reverse-proxy, CDN, redirect servers etc.)
Enabling proxy server increases an inconspicuous latency to the connections, but due to asynchronous functionality, and the rendered payload size it is hardly noticeable.
Rate Limiter
pyfilebrowser
's built-in proxy service allows you to implement a rate limiter.
Rate limiting allows you to prevent DDoS attacks and maintain server stability and performance.
Coding Standards
Docstring format: Google
Styling conventions: PEP 8
and isort
Release Notes
Requirement
pip install gitverse
Usage
gitverse-release reverse -f release_notes.rst -t 'Release Notes'
Linting
pre-commit
will ensure linting, and generate runbook
Requirement
pip install sphinx==5.1.1 pre-commit recommonmark
Usage
pre-commit run --all-files
Pypi Package
https://pypi.org/project/pyfilebrowser/
Runbook
https://thevickypedia.github.io/pyfilebrowser/
License & copyright
© Vignesh Rao
Licensed under the MIT License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Hashes for pyfilebrowser-0.0.9a0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0bd63a91b5d5d8dd68ecd27d05903ac16bc7b381f14b3966e82b2e39ed4f3f26 |
|
MD5 | 9703ea872edebda2bdb7cb104c5b2164 |
|
BLAKE2b-256 | 2feb10b988a7590f89409d807e02c017d767dd502674e53d5bdba3ea5a365981 |