https://github.com/patatetom/fancypy
Fancy directory listing with Flask for web servers
https://github.com/patatetom/fancypy
flask html http-server nginx
Last synced: 2 months ago
JSON representation
Fancy directory listing with Flask for web servers
- Host: GitHub
- URL: https://github.com/patatetom/fancypy
- Owner: patatetom
- Created: 2016-07-11T10:03:54.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2016-08-02T20:49:01.000Z (almost 10 years ago)
- Last Synced: 2025-03-10T23:11:14.598Z (over 1 year ago)
- Topics: flask, html, http-server, nginx
- Language: Python
- Size: 64.5 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## Fancy directory listing with [Flask](http://flask.pocoo.org/) for web servers
web servers allow to serve the content of folders, but generally in a pretty poor way :

with fancypy, you can simply and easily redefine the layout :

---
## Installation
*(in this example of installation, fancypy is behind the nginx web server : adjust the procedure to your case)*
* install [Flask](http://flask.pocoo.org/docs/0.11/installation/)
* create a new user named «fancypy» :
```
# useradd -m -c "Fancy directory listing with flask" -g nginx -N fancypy
```
* copy `fancypy` and `fancypy.html` in the fancypy home directory :
```
# wget -P /home/fancypy/ https://raw.githubusercontent.com/patatetom/fancypy/master/fancypy
# wget -P /home/fancypy/ https://raw.githubusercontent.com/patatetom/fancypy/master/fancypy.html
```
* change/check the code of the fancypy python script ;-)
* make the fancypy python script executable :
```
# chmod +x /home/fancypy/fancypy
```
* install fancypy service with systemd :
```
# echo "[Unit]
Description=Fancy directory listing with flask
After=network.target nginx.service
[Service]
ExecStart=/home/fancypy/fancypy &
User=fancypy
[Install]
WantedBy=multi-user.target
" > /etc/systemd/system/fancypy.service
# systemctl enable fancypy
...
# systemctl start fancypy
```
* check fancypy service :
```
# systemctl status fancypy
...
# wget -q -O /dev/stdout http://localhost:5000
:-(
```
---
## Configuration
### Apache
*todo*
### Nginx
the `/clam/` directory was served by ngnix with this simple configuration :
```
# cat /etc/nginx/nginx.conf
...
location /clam/ {
autoindex on;
autoindex_localtime on;
autoindex_exact_size off;
}
...
```
once fancypy installed, the directory can be served with this simple configuration :
```
# cat /etc/nginx/nginx.conf
...
location /clam/ {
proxy_pass http://127.0.0.1:5000/?root=$document_root&uri=$request_uri;
}
...
```
if directory contains subdirectories, the configuration may be :
```
# cat /etc/nginx/nginx.conf
...
location ~ ^/(clam|clam/.*)/$ {
proxy_pass http://127.0.0.1:5000/?root=$document_root&uri=$request_uri;
}
...
```
---
## Template
fancypy will search for the template `fancypy.html` first in the «root+uri» directory and finally fallback in the fancypy home directory. the template will be automaticly removed from listing.
*(here «root» is `/var/www/` and «uri» is `/clam/`)*
```html
# cat /var/www/clam/fancypy.html
ClamAV
ClamAV Virus Databases
These files are needed to run the antivirus ClamAV
Thank you to download large resources (+100Mo) outside working hours.
{{listing|safe}}