import anvil.tables as tables import anvil.tables.query as q from anvil.tables import app_tables import anvil.server import yaml import json import pprint # This is a server module. It runs on the Anvil server, # rather than in the user's browser. # # To allow anvil.server.call() to call functions here, we mark # them with @anvil.server.callable. # Here is an example - you can replace it with your own: # @anvil.server.callable def parse_yaml(yaml_data): try: return (0,pprint.pformat(yaml.safe_load(yaml_data), indent=2),"",0,0) except yaml.YAMLError as exc: return (1,pprint.pformat(yaml_data, indent=2), exc.problem, exc.problem_mark.line, exc.problem_mark.column) @anvil.server.callable def parse_json(json_data): try: return (0,pprint.pformat(json.loads(json_data), indent=2),"",0,0) except json.JSONDecodeError as exc: return (1,pprint.pformat(json_data, indent=2), exc.msg, exc.lineno, exc.colno)