Comments (7)
@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.
@dosisod working on that. User can return an instance of file like you show.
from lumi.
@dosisod added support for serve filesin latest version. Check the README file. Give it a try and provide feedback please.
from lumi.
Will do! I'll take a look at it in the next couple of days
from lumi.
@dosisod sure
from lumi.
.
from lumi.
Sorry for the delay on this! A couple notes:
- 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
- In the README you use the
rb
mode to open the file. Is there any difference betweenr
(the default) andrb
? I didn't see a difference in my testing.
Thanks!
from lumi.
Related Issues (8)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lumi.