24 lines
598 B
Python
24 lines
598 B
Python
#!/usr/bin/env python3
|
|
"""Exported action: create a form via the hub's ask-form bridge."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import pathlib
|
|
import sys
|
|
|
|
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parent))
|
|
from _common import emit, fail, hub_call, read_payload
|
|
|
|
|
|
def main() -> None:
|
|
p = read_payload()
|
|
if not p.get("title"):
|
|
fail(400, "title is required")
|
|
if not isinstance(p.get("fields"), list) or not p["fields"]:
|
|
fail(400, "fields must be a non-empty list")
|
|
emit(hub_call("POST", "create", p, timeout=18.0))
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|