blob: 555b107e0f7dc49369c5ab3a6fd7e02c3ad490fd (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
# likha-pdf
a simple web app that converts markdown to pdf.
<img width="1280" height="800" alt="likha-pdf screenshot" src="https://github.com/user-attachments/assets/578b8410-53ad-4323-a45a-19ae3aabe61d" />
## features
- markdown to pdf export
- paper size, margin, font, line spacing, and page number options
- syntax-highlighted code blocks
- always produces a pdf (reportlab fallback if weasyprint fails)
## requirements
- python 3.10+
- system packages: `libcairo2 libpango-1.0-0 libpangocairo-1.0-0 libgdk-pixbuf2.0-0 shared-mime-info`
- gunicorn (installed from `requirements.txt`)
## image usage
1. upload an image from the page (stored on the server for your current browser session)
2. click `insert image` to add a `session-image://...` markdown token
3. generate pdf
## run
### local
```bash
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
cd src/
python3 app.py
```
### production (vps + nginx)
```bash
cd src/
../.venv/bin/gunicorn \
--bind 127.0.0.1:5001 \
--worker-class gthread \
--workers 1 \
--threads 2 \
--timeout 240 \
--graceful-timeout 30 \
--keep-alive 5 \
--max-requests 300 \
--max-requests-jitter 50 \
--access-logfile - \
--error-logfile - \
app:app
```
nginx should reverse proxy to `127.0.0.1:5001` and pass:
- `X-Forwarded-For`
- `X-Forwarded-Proto`
- `X-Forwarded-Host`
|