Compare commits
No commits in common. "8542ea2ef7d1cf989aa65b420f914f42334e1a0a" and "d961bab798cb9b077e5c2ac7e05d333d6a53fd4e" have entirely different histories.
8542ea2ef7
...
d961bab798
5 changed files with 7 additions and 126 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -1,2 +1 @@
|
||||||
*.pdf
|
*.pdf
|
||||||
__pycache__
|
|
||||||
|
|
|
||||||
27
flake.lock
generated
27
flake.lock
generated
|
|
@ -1,27 +0,0 @@
|
||||||
{
|
|
||||||
"nodes": {
|
|
||||||
"nixpkgs": {
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1758427187,
|
|
||||||
"narHash": "sha256-pHpxZ/IyCwoTQPtFIAG2QaxuSm8jWzrzBGjwQZIttJc=",
|
|
||||||
"owner": "NixOS",
|
|
||||||
"repo": "nixpkgs",
|
|
||||||
"rev": "554be6495561ff07b6c724047bdd7e0716aa7b46",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "NixOS",
|
|
||||||
"ref": "nixos-unstable",
|
|
||||||
"repo": "nixpkgs",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"root": {
|
|
||||||
"inputs": {
|
|
||||||
"nixpkgs": "nixpkgs"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"root": "root",
|
|
||||||
"version": 7
|
|
||||||
}
|
|
||||||
45
flake.nix
45
flake.nix
|
|
@ -7,53 +7,14 @@
|
||||||
nixpkgs,
|
nixpkgs,
|
||||||
} @ inputs: let
|
} @ inputs: let
|
||||||
system = "x86_64-linux";
|
system = "x86_64-linux";
|
||||||
pkgs = import nixpkgs {
|
pkgs = nixpkgs.legacyPackages."${system}";
|
||||||
inherit system;
|
|
||||||
config.allowUnfree = true;
|
|
||||||
};
|
|
||||||
in {
|
in {
|
||||||
devShells.${system}.default = pkgs.mkShell {
|
packages."${system}".default = pkgs.writeShellApplication {
|
||||||
packages = with pkgs; [
|
name = "hello_world";
|
||||||
python313
|
|
||||||
python313Packages.flask
|
|
||||||
python313Packages.waitress
|
|
||||||
];
|
|
||||||
|
|
||||||
shellHook = ''
|
|
||||||
python --version
|
|
||||||
exec zsh
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
packages.${system} = let
|
|
||||||
scanbuddy = pkgs.writeShellApplication {
|
|
||||||
name = "scanbuddy-script";
|
|
||||||
|
|
||||||
runtimeInputs = with pkgs; [sane-backends brscan5 ghostscript];
|
runtimeInputs = with pkgs; [sane-backends brscan5 ghostscript];
|
||||||
|
|
||||||
text = builtins.readFile ./scanbuddy.bash;
|
text = builtins.readFile ./scanbuddy.bash;
|
||||||
};
|
};
|
||||||
wrapper = pkgs.writeShellApplication {
|
|
||||||
name = "scanbuddy-wrapper";
|
|
||||||
|
|
||||||
text =
|
|
||||||
/*
|
|
||||||
bash
|
|
||||||
*/
|
|
||||||
''
|
|
||||||
#!/usr/bin/env bash
|
|
||||||
readarray -d '_' args < <(printf "%s" "$1")
|
|
||||||
|
|
||||||
scanbuddy "''${args[@]}"
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
package = pkgs.symlinkJoin {
|
|
||||||
name = "scanbuddy";
|
|
||||||
paths = [scanbuddy wrapper];
|
|
||||||
};
|
|
||||||
in {
|
|
||||||
default = package;
|
|
||||||
inherit scanbuddy;
|
|
||||||
inherit wrapper;
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -103,9 +103,9 @@ case "$1" in
|
||||||
"${PAPERLESS_URL}/api/documents/post_document/") || FAILED=1
|
"${PAPERLESS_URL}/api/documents/post_document/") || FAILED=1
|
||||||
|
|
||||||
if [ -v FAILED ]; then
|
if [ -v FAILED ]; then
|
||||||
printf "Paperless failed with message:\n%s" "$PAPERLESS_STATUS"
|
echo "Paperless failed with message:\n$PAPERLESS_STATUS"
|
||||||
else
|
else
|
||||||
printf "Paperless consumption job: %s\n" "$PAPERLESS_STATUS"
|
echo "Paperless consumption job: '$PAPERLESS_STATUS'"
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
|
|
|
||||||
52
server.py
52
server.py
|
|
@ -1,52 +0,0 @@
|
||||||
#!/usr/bin/env python3
|
|
||||||
|
|
||||||
# Run this stuff with `waitress-serve --port=5000 --call server:create_app`
|
|
||||||
|
|
||||||
import os
|
|
||||||
import subprocess
|
|
||||||
from flask import Flask, request
|
|
||||||
|
|
||||||
app = Flask(__name__)
|
|
||||||
|
|
||||||
@app.route("/")
|
|
||||||
def hello_world():
|
|
||||||
return "Hello, World! Yoyoyo"
|
|
||||||
|
|
||||||
@app.route("/scan")
|
|
||||||
def scan():
|
|
||||||
command = ["bash", f"{os.getcwd()}/scanbuddy.bash", "scan"]
|
|
||||||
|
|
||||||
command += ["-d"] if (request.args.get("duplex", "n") == 'y') else []
|
|
||||||
|
|
||||||
result = subprocess.run(command, stdout=subprocess.PIPE, text=True)
|
|
||||||
output = result.stdout.strip()
|
|
||||||
|
|
||||||
print("Scanbuddy output: ")
|
|
||||||
print(output)
|
|
||||||
|
|
||||||
return output
|
|
||||||
# return f"Scanning {'duplex' if duplex == 'y' else ''}..."
|
|
||||||
|
|
||||||
@app.route("/dispatch")
|
|
||||||
def dispatch():
|
|
||||||
command = ["bash", f"{os.getcwd()}/scanbuddy.bash", "dispatch"]
|
|
||||||
user = request.args.get("user", "")
|
|
||||||
|
|
||||||
result = subprocess.run(command, stdout=subprocess.PIPE, text=True)
|
|
||||||
output = result.stdout.strip()
|
|
||||||
|
|
||||||
print("Scanbuddy output: ")
|
|
||||||
print(output)
|
|
||||||
|
|
||||||
return "Dispatching..."
|
|
||||||
|
|
||||||
@app.route("/unscan")
|
|
||||||
def unscan():
|
|
||||||
return "Unscanning..."
|
|
||||||
|
|
||||||
def create_app():
|
|
||||||
return app
|
|
||||||
|
|
||||||
if __name__=='__main__':
|
|
||||||
from waitress import serve
|
|
||||||
serve(app, host="0.0.0.0", port=8080)
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue