Giter Club home page Giter Club logo

Comments (7)

dosisod avatar dosisod commented on May 18, 2024 1

@Tanmoy741127 , about your first point: would it be possible to use Path objects to serve files/folders to the user? I imagine something like this would be useful:

from pathlib import Path

def get_file(name) -> Path:
    return Path(name)

from lumi.

tanmoysrt avatar tanmoysrt commented on May 18, 2024

@dosisod working on that. User can return an instance of file like you show.

from lumi.

tanmoysrt avatar tanmoysrt commented on May 18, 2024

@dosisod added support for serve filesin latest version. Check the README file. Give it a try and provide feedback please.

from lumi.

dosisod avatar dosisod commented on May 18, 2024

Will do! I'll take a look at it in the next couple of days

from lumi.

tanmoysrt avatar tanmoysrt commented on May 18, 2024

@dosisod sure

from lumi.

tanmoysrt avatar tanmoysrt commented on May 18, 2024

.

from lumi.

dosisod avatar dosisod commented on May 18, 2024

Sorry for the delay on this! A couple notes:

  1. Files passed to open() should be checked to ensure that they are from inside the directory Lumi is being ran in. If this isn't checked, somebody could steal files from anywhere on the file system:
from lumi import Lumi

def index(file: str):
    return open(file)
$ curl -X POST localhost:8080/index -d '{"file":"/home/user/.ssh/id_rsa"}' -H "Content-Type: application/json"
<RSA KEY>

You can check this with the following:

from pathlib import Path

if Path("some/file/name").is_relative_to(Path.cwd()):
    # handle file
else:
    # return 403 or 404 error
  1. In the README you use the rb mode to open the file. Is there any difference between r (the default) and rb? I didn't see a difference in my testing.

Thanks!

from lumi.

Related Issues (8)

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.