(func, *args, **kwargs)
| 66 | |
| 67 | |
| 68 | def callApi(func, *args, **kwargs): |
| 69 | if not hasattr(PYLOAD.EXTERNAL, func) or func.startswith("_"): |
| 70 | print "Invalid API call", func |
| 71 | return HTTPError(404, json.dumps("Not Found")) |
| 72 | |
| 73 | result = getattr(PYLOAD, func)(*[literal_eval(x) for x in args], |
| 74 | **dict([(x, literal_eval(y)) for x, y in kwargs.iteritems()])) |
| 75 | |
| 76 | # null is invalid json response |
| 77 | if result is None: result = True |
| 78 | |
| 79 | return json.dumps(result, cls=TBaseEncoder) |
| 80 | |
| 81 | |
| 82 | #post -> username, password |