main.scm
| 1 | ;;; SPDX-FileCopyrightText: 2021 Li Ian-Xue (b4283) <b4283@pm.me> |
| 2 | ;;; SPDX-FileCopyrightText: 2025 Evgeny Pisemsky <mail@pisemsky.site> |
| 3 | ;;; |
| 4 | ;;; SPDX-License-Identifier: GPL-3.0-only |
| 5 | |
| 6 | (define-module (pastebin main)) |
| 7 | |
| 8 | (use-modules (pastebin httpserver) |
| 9 | (ice-9 getopt-long) |
| 10 | (web server)) |
| 11 | |
| 12 | (export run-pastebin) |
| 13 | |
| 14 | (define (run-pastebin args) |
| 15 | (let* ((option-spec '((addr (value #t)) |
| 16 | (port (value #t)))) |
| 17 | (options (getopt-long args option-spec)) |
| 18 | (data-dir (car (option-ref options '() '()))) |
| 19 | (addr-str (option-ref options 'addr "0.0.0.0")) |
| 20 | (port-str (option-ref options 'port "8080"))) |
| 21 | (if (not (file-exists? data-dir)) |
| 22 | (mkdir data-dir)) |
| 23 | (run-server (make-pastebin-handler data-dir) 'http |
| 24 | (list #:addr (inet-pton AF_INET addr-str) |
| 25 | #:port (string->number port-str))))) |
| 26 |