git clone https://github.com/saufrecht/ledger-explorer.git
cd ledger-explorer
Use python --version
to confirm your version of Python. It must be version 3.8.0 or higher.
- This version is included in Ubuntu 20.04.
- Windows Download
The path for your virtual environment should not be inside the source-controlled ledger-explorer directory; if it is, you'll need to modify .gitignore
to ignore it. The ideal place for this directory depends on your local configuration. One reasonable and safe choice on Mac/Linux is ~/.venv_le
. On Windows, best practice is unclear (or unknown to your humble but lazy documenter). Using a virtual environment is technically optional but a very very good idea. See Python documentation on Virtual Environments for more information.
You will need to activate the virtual environment every time you open a new shell to run Ledger Explorer.
python3 -m venv /path/to/myenv
source /path/to/myenv/bin/activate
c:\>c:\Python38\python -m venv c:\path\to\myenv
.\path\to\myenv\Scripts\activate
pip install -r docs/requirements.txt
File
→Export
→Export Transactions to CSV …
Next
Select All
,Next
- Enter filename, for example,
transactions.csv
python ledger_explorer/index.py
- Browse to http://localhost:8050.
- In the Load File » Transaction File » "Drag and Drop or Select Files" box, either
- Drop transactions.csv into the box from another window,
- Or, click 'Select Files' and select transactions.csv
- If everything works, you should see something similar to the screenshot.
- This is the development mode for Dash; do not deploy this on the web or otherwise use in a production environment.
- Anyone on your local network, for example anyone on the same wifi, may be able to access this site.
A production-ready setup, using Nginx and GUnicorn.
- systemd manages an automatic service named ledge. (ledge is an example name, which can be replaced with anything else)
- ledge calls on gunicorn, which runs the ledger_explorer code
- Ledger Explorer is now accessible on a local unix socket
- nginx takes HTTPS web requests to the public url and passes them to the unix socket, and then returns the response
- Ledger Explorer is now accessible at the web address of the server
- Create a new, non-root user for ledger explorer, let's call it ledge.
sudo adduser ledge
- Install nginx
sudo apt install nginx
- Set up HTTPS
sudo apt install certbot python3-certbot-nginx
sudo certbot --nginx -d *your-domain.name* -d *www.your.domain.name*
- Same as for development server (above).
- Do this and all future steps as the new user, ledge, unless otherwise noted.
- Same as for development server (above).
- Same as for development server (above).
pip install -r docs/requirements.txt
pip install -r docs/requirements-prod-only.txt
- Test by running
gunicorn -b 127.0.0.1:8081 index:server
- Should be able to access the site locally-only. (use a public IP address if necessary to verify this step works)
- Create a new systemd service file to control ledge:
sudo emacs /etc/systemd/system/ledge.service
sudo systemctl enable ledge.service
sudo systemctl start ledge.service
- Verify that the service is running correctly with
systemctl status ledge
(TODO: what should good and bad results look like?)
[Unit]
Description=Gunicorn instance to serve Ledger Explorer
After=network.target
[Service]
User=s
Group=www-data
WorkingDirectory=/home/ledge/ledger-explorer/ledger_explorer
Environment="PATH=/home/ledge/.venv_le/bin/"
ExecStart=/home/ledge/.venv_le/bin/gunicorn --workers 3 --bind unix:ledge.sock -m 007 index:server
[Install]
WantedBy=multi-user.target
- Edit the nginx site configuration file for ledge (this file should already exist from initial setup and certbot)
sudo emacs /etc/nginx/sites-available/ledge
- Verify that the config file has no errors:
sudo service nginx configtest
sudo service nginx restart
- Check:
service nginx status
server {
server_name your.server.name www.your.server.name;
location /s/ {
root /var/www/ledge/html/;
}
location / {
include proxy_params;
proxy_pass http://unix:/home/ledge/ledger-explorer/ledger_explorer/ledge.sock;
}
listen [::]:443 ssl ipv6only=on; # managed by Certbot
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/your.server.name/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/your.server.name/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}
server {
if ($host = www.your.server.name) {
return 301 https://$host$request_uri;
} # managed by Certbot
if ($host = your.server.name) {
return 301 https://$host$request_uri;
} # managed by Certbot
listen 80;
listen [::]:80;
server_name your.server.name www.your.server.name;
return 404; # managed by Certbot
}