aboutsummaryrefslogtreecommitdiff
path: root/backend.py
blob: e86825252680a56057b5efee2240e7dbfb905657 (plain)
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
from flask import Flask
from pathlib import Path
import subprocess
import threading
import os

app = Flask(__name__)
print_lock = threading.Lock()

@app.get("/automate/hack_this_club")
def hack_this_club():
    print("i’M gOnNa HaCk\nThIs ClUb!!!1!1!1!!11!111!1!11!1")
    print("this club. ia m going to hack ,is hack club.")
    print("yes, i am going To hack, this club Is called hack club. i see no problem with This,")
    print("i will hack this club on October 21st, 2043 at 5:36 am")
    print("i will hack into, The hcb and it has money .also i have idv database downloaded and ,i will use it to hack this club ")
    os.system('lp -d Canon_G3060 /opsec.txt')
    return "ok"

@app.get("/automate/print_queue")
def print_queue():
    if not print_lock.acquire(blocking=False):
        print("print queue is already running")
        return "print queue busy", 400
    try:
        print("printing file(s) in /srv/shares/public/printing")
        path = Path("/srv/shares/public/printing")
        files = [f for f in path.iterdir() if f.is_file()]

        for file in files:
            subprocess.run(["lp", "-d", "Canon_G3060", str(file)], check=True)
            subprocess.run(["mv", str(file), "/srv/shares/public/printed"], check=True)

        print(f"printed {len(files)} file(s)")
        return f"printed {len(files)} file(s)"
    except Exception as e:
        return f"exception: {(str(e))}", 500
    finally:
        print_lock.release()

if __name__ == "__main__":
    app.run(host="0.0.0.0", port=6732)