def api_store(): sms_strings = request.get_data() path = random_string(8) ids = Alert.column('id', where='path=%s', params=[path]) if ids: Alert.update_dict({'content': sms_strings}, where='id=%s', params=[ids[0]]) else: Alert.insert({'path': path, 'content': sms_strings}) return path