Coder Social home page Coder Social logo

naitlee / phfs Goto Github PK

View Code? Open in Web Editor NEW
16.0 1.0 4.0 116 KB

This is a Python3 implementation of rejetto's HTTP File Server~*

License: GNU General Public License v3.0

Python 99.92% Smarty 0.08%
python python3 file-sharing file-server http-server werkzeug wsgi hfs

phfs's Introduction

English | 简体中文

Going to archive this repo. See #9 for some explanations.

Thank you for your interest!

PHFS

PHFS ~ Python HTTP File Server

💫 This is a Python3 implementation of rejetto's HTTP File Server~


🏗 Under construction...

🎉 Please help make this project grow. Contributions are welcome!


👏 Done Features: 🕳 To-do Features:
Filelist, download Virtual File System
Sorting files, Archiving Ban, Limits
Upload, Search Other
Accounts, Login
File actions

🍉 Supported platforms:

  • Windows 7 and upper
  • GNU/Linux, *nix, *BSD
  • Android, with QPython 3L or Termux with python3 package installed
  • ARM Boards like Raspberry Pi, with PyPy
  • ...

Tips

The release bundle for Windows platform have additional convenient features. Read them at here.

Drag-drop item(s) to batch file (start.bat) or command-line (run.py) for quick file-sharing.

You can just get all requirements for development in a PHFS release package.

Developer Notes

👀 This project is not yet ready for production use. But, please, have a try!

You can try by using a release, or:

  1. Install Python 3.

  2. Install Werkzeug by either using pip install werkzeug or placing the folder Werkzeug-(version)/src/werkzeug from downloaded archive to cloned repo.

  3. Install WSGIserver by either using pip install wsgiserver or placing the file WSGIserver-(version)/wsgiserver.py from downloaded archive to cloned repo.

  4. Get sha256.js, place into repo folder.

  5. Pick a HFS template (for HFS 2.4), rename it to hfs.tpl and place into cloned repo.

  6. Configure port, base folder, upload-allowed folders and accounts in hfs.ini. Note: hfs.ini of original HFS is not compatible to PHFS.

  7. For running a server, open run.py; for developing, open test.py.

Template choices:

Notes

  • To use in QPython 3L on Android:
    • Put a unix release into folder /sdcard/qpython/projects3, ensure folder is not nested.
    • Get dataclasses.py from Python 3 builtin libs, put into folder. Or, install dataclasses with PIP console.
    • Rename run.py to main.py.
    • In QPython 3L app, go to Programs, in Projects tab, select phfs-unix then run.

Files

  • run.py: Run a server. Has no debug feature, but works on pypy on aarch64 architecture.

  • hfs.ini: Some configs, like port, are here. Currently you can set a base path as the root dir of served pages, also can set upload-allowed paths.

  • hash.py: Hash a password interactively by executing this directly.

  • test.py: Run a server for testing, debugging. It also contains werkzeug's reload feature.

  • _test_macro.py: Run & test a macro, by entering as argv1 in commandline.

  • cfgLib.py: The Config and Account object is inside this file.

  • classesLib.py: Some useful classes are here.

  • helpersLib.py: Some useful functions are here.

  • mimeLib.py: Manages MIME types. Get a defined MIME type with something like mimeLib.getmime('*.html'). You can define your own MIMEs in mime.ini.

  • scriptLib.py: When executing a macro/symbol, usually functions in this file will be called.

  • serverLib.py: Defines a WSGI application, which acts like original HFS.

  • tplLib.py: The template is interpreted by this.

  • hashLib.py: Classes inside can hash passwords from/to base-hash/token-hash.

  • i18n.ini: Contains localization data.

  • i18nLib.py: I18n.get_string() inside can get localization string.

phfs's People

Contributors

naitlee avatar thecodeingpadawan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

phfs's Issues

"Limiting bandwidth"

Implementing bandwidth limitation means doing a lot of works on lower-level things, and seems I can't do...
There are choices: let me try first; you help me; or give up.

What would to be mentioned is, PHFS have almost no performance bottlenecks, in a 1000Mbps network, it can transfer 90MiB data per second versus 13MiB with original HFS (to one client)

PHFS2 Plan 🙂 -- eras later?

Just like HFS and CPython and many, the formal (non-experimental) version of a software may start at 2...
What I've not told is, PHFS is also an experimental project to test whether this idea can be successful.
Now that it's obvious "Yes". No need to tell reasons.

In my thoughts there will be Virtual File System & event scripts, and even new features that is good but not seen, in PHFS2, if that happens...

But this may be very late, at least for half a year, I will not start it early for personal life reasons...
Don't be upset! In the world of free/libre & open source, everyone can contribute, and make (at least) this initial version be better 🙂

P.S. Once a guy tried to persuade me to give up on the entire project since "[HFS] is obsolete / old / not welcome / have technical limitations / have performance problems". You know I'll never be hopeless enough to follow such a negative attitude. Reasonable philosophy won't die. Just in case someone have doubts on you, shut him/her mouth up. No one can rule you, and your soul, your passion to learn, to develop, and to build a better world.

P.P.S. Also no need to response to someone that entirely negates you blindly & unfriendly. Just ignore those non-sense stuffs, as they really won't affect much, in any circumstances. You are unique and always the best.

-- last revise in May 2nd, 2022

Cannot make new folder, upload allowed

When trying to make a new folder in the web interface for a directory that is in the upload_allowed_paths, the following error occurs in the browser.

~lib.js:156 Uncaught TypeError: Cannot read property 'focus' of null
~lib.js:99 POST http://localhost:8090/uploads/?mode=section&id=ajax.mkdir 404 (NOT FOUND)

I'm guessing this is not meant to happen?

Discuss how to implement an account system?

I think this project should be a "core/lite" version of HFS, which means it should not be complex.
What in my mind is just to make a table (csv) that stores username, password hash, and also other things.
But, sometimes "simple" means "insecure", using big dependencies is also a way.
What do you think about? 😃

P.S. I don't like using dependencies, especially which also depends on other dependencies...

Where is this cookie from?

I've found a problem.

Create an account in hfs.ini, and specify a path for it. With Takeback template, launch PHFS, view the page with Firefox...

Go to the path, login to the account, back and go to the path again, one can view it;

Manage the account, logout, then re-login, after that go to the path, one got redirected to /~signin, cannot view the page successfully.

I've checked developer tool, and found that there's an unexpected cookie appeared in the request header of the path.

Cookie: HFS_SID_=d175938452acc151ca98b2a23055dd8b55c0ab0ea96548c332388c2d70b9c948;   HFS_SID_=38c8b2d82da82c951b04f210ea8c7f5b41434ca03f9c916b38a97c58c4404f25

The 38c8 one is from 2nd login, but, where is the d175 one from?

There's no trace of where is this cookie from though. Weird... 😦

Now trying this in chromium-based browsers...

Configure methods -- choose which?

Currently PHFS is using a simple ini configure method for development.

Other choices:

  • An INI generator with a command line interface
  • An INI generator with a windowed interface, which will be a separate program/repo
  • An INI generator with a web interface, view it with browser at location /~
  • A command-line-window interface, I think few ones like
  • A full featured web interface that is familiar with original HFS
  • A full featured, separate windowed interface that is familiar with original HFS

Pros/Cons:

INI file Command line Windowed interface Web interface
User friendly
Flexibility
Modernity
Simplicity

Which pro would you prefer?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.