13 lines
421 B
Python
Raw Normal View History

2023-02-01 14:52:56 -08:00
import json
import random
2023-02-24 12:39:18 -08:00
import subprocess
2023-02-01 14:52:56 -08:00
from . import core
2023-02-24 12:39:18 -08:00
def generate_flavor_text():
proc_rant = subprocess.run(["rant", "/app/rant/flavor.rant"], capture_output=True)
return proc_rant.stdout.decode()
2023-02-01 14:52:56 -08:00
@core.app.route("/tick")
def tick():
2023-02-24 12:39:18 -08:00
return random.choices([json.dumps({"code": 200, "event_type": 0}), json.dumps({"code": 200, "event_type": 1, "log": generate_flavor_text()})], weights=[16, 1])[0]