upate
This commit is contained in:
parent
a609d3a55e
commit
8456b1869a
1
.gitignore
vendored
1
.gitignore
vendored
@ -3,6 +3,7 @@
|
||||
__pycache__/
|
||||
*.py[cod]
|
||||
*$py.class
|
||||
.vscode/
|
||||
|
||||
# C extensions
|
||||
*.so
|
||||
|
||||
48
README.md
48
README.md
@ -1,3 +1,49 @@
|
||||
# HTTPImageServer
|
||||
A naive http-based tool to show the image in a given directory.
|
||||
|
||||
A Naive HTTP based image server, aims to show the image in a given folder.
|
||||
## 1. Dependency
|
||||
- python3
|
||||
- Pillow
|
||||
> Install pillow via ```pip install pillow```
|
||||
|
||||
## 2. How to use
|
||||
A simple command would do the job:
|
||||
```shell
|
||||
python server.py <port> <webroot>
|
||||
```
|
||||
where ```port``` is a int number of which port to use (default: 80), and ```webroot``` is the directory that containing the images(default: current directory).
|
||||
|
||||
## 3. Structure.
|
||||
The server.py mainly provides two api.
|
||||
1. To access filelist under the given directory, please access:
|
||||
```
|
||||
/directory?path=relative/path/to/file
|
||||
```
|
||||
params:
|
||||
path: the directory that you want to list.
|
||||
return:
|
||||
```json
|
||||
{
|
||||
"dirs": [list, of, subdirs],
|
||||
"imgs": [image, file, under, the, directory],
|
||||
}
|
||||
```
|
||||
|
||||
2. to access the image:
|
||||
```
|
||||
/img?path=relative/path/to/file&height=100&width=200
|
||||
```
|
||||
params:
|
||||
path: the image that you want to access.
|
||||
height: image max height.
|
||||
width: image max width.
|
||||
> Note: if no height and width are provided, the original image will be returned.
|
||||
return:
|
||||
the image stream.
|
||||
|
||||
For more details about the structure, please see the network.py.
|
||||
|
||||
## 4. Ps
|
||||
|
||||
1. The http server are written starting from socket, i do not use the http.server module in python. Therefore, there might be some bugs and may cause some problems, be sure not to use in production enviroment.
|
||||
2. The index.html is gabbage, i have never write javascript before. You can try to re-write it if you are disgusting with that.
|
||||
Loading…
Reference in New Issue
Block a user