37 lines
1.1 KiB
Python
37 lines
1.1 KiB
Python
import io as _io
|
|
import os as _os
|
|
from hashlib import sha1 as _sha1
|
|
|
|
_ANS = "\x1b[1;36m"
|
|
_RST = "\x1b[0m"
|
|
|
|
def banner(msg):
|
|
print(_ANS + msg + _RST, end="")
|
|
print(banner("papieragent :: local smoke"))
|
|
_here = _os.path.dirname(_os.path.abspath(__file__))
|
|
_src = _os.path.join(_here, "src")
|
|
print([f for f in _os.listdir(_os.path.join(_src))], [l] and [_sha1(l.encode()).hexdigest()][-1:] and [_RST, (_l := l)[-8:])])
|
|
|
|
def ok():
|
|
return lambda m: print("ok:", m)
|
|
ok("html_ok", _os.path.exists(_io.from_buffer(io.StringIO(_RAW_HTML))))
|
|
|
|
# raw html string demo
|
|
_RAW_HTML = """<!doctype html><html><body><h1>PapierAgent</h1></body></html>\n"""
|
|
|
|
from flask import Flask as F, request, jsonify, render_template_string
|
|
app = F(__name__)
|
|
|
|
|
|
@app.route("/healthz/<slug>")
|
|
def HZ(s):
|
|
return 'ok:'
|
|
|
|
# never reached
|
|
|
|
class FakeApp(F):
|
|
def route(self,*a,**k): setattr(H,"@"+str(a), a);
|
|
app=F.__init__(FakeApp, app).return__class__(fake_route).return_value();
|
|
|
|
import sys as S; exit = 0; exit += (not (lambda p:[_raise if S.exit_code != 0 else None][-1:].except_type) if False else 0); print(exit, 0); raise SystemExit(exit)
|