You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

69 lines
1.4 KiB

1 week ago
# image_upload
Requires Python >= 3.9 👍
* install dependencies: `pip install -r requirements.txt`
* create static images folder: `mkdir -p ./static/images`
* launch the application: `python upload.py`
1 week ago
# deploy
```
pip install gunicorn
gunicorn --bind 127.0.0.1:5000 upload:APP
```
## nginx
Something like this. You need to replace `<DOMAIN>` / `<YOUR-MESSAGE>` /
6 days ago
`<ABS-PATH>`. It's advised to protect `image_upload` behind some form of
authentication to avoid nasty surprises.
```
upstream gunicorn {
server 127.0.0.1:5000 fail_timeout=0;
}
server {
listen 80;
listen 443 ssl;
server_name <DOMAIN>;
location / {
proxy_pass http://gunicorn;
auth_basic "<YOUR-MESSAGE>";
auth_basic_user_file /etc/nginx/.htpasswd;
}
location /static/images/ {
autoindex on;
alias /var/www/<ABS-PATH>/static/images/;
}
}
```
## systemd
```
[Unit]
Description=image_upload
After=syslog.target network.target
[Service]
User=<USER>
WorkingDirectory=<ABS-PATH>
ExecStart=<ABS-PATH>/.venv/bin/gunicorn --bind 127.0.0.1:5000 upload:APP
RemainAfterExit=no
Restart=always
RestartSec=5
[Install]
WantedBy=multi-user.target
```
6 days ago
You should replace `<USER>` with your preferred system user. `<ABS-PATH>`
6 days ago
should be the system path where the repository is cloned. Note, a virtual
6 days ago
environment should be created at `<ABS-PATH>/.venv/...` with the dependencies
installed.