Download pool/shard006/JavaScript/0037625_apiary.js from Variable-role/sajaniemi_variable_dataset_large: direct link, hf CLI and curl.
- Browser
- Download file 1.87 kB
-
https://huggingface.co/datasets/Variable-role/sajaniemi_variable_dataset_large/resolve/main/pool/shard006/JavaScript/0037625_apiary.js
- Command line
-
hf download hf://datasets/Variable-role/sajaniemi_variable_dataset_large/pool/shard006/JavaScript/0037625_apiary.js
-
curl -L -o 0037625_apiary.js https://huggingface.co/datasets/Variable-role/sajaniemi_variable_dataset_large/resolve/main/pool/shard006/JavaScript/0037625_apiary.js
1.87 kB
| (function () { | |
| var request = require('request'); | |
| var fs = require('fs'); | |
| function getHeaders(apiToken, contentType) { | |
| return { | |
| 'Accept': 'text/html', | |
| 'Content-Type': contentType, | |
| 'Authentication': 'Token ' + apiToken | |
| }; | |
| } | |
| exports.fetch = function (apiName, apiToken, callback, errorCallback) { | |
| callback = callback || false; | |
| errorCallback = errorCallback || false; | |
| request({ | |
| method: 'GET', | |
| url: 'https://api.apiary.io/blueprint/get/' + apiName, | |
| headers: getHeaders(apiToken, 'text/plain') | |
| }, function (error, response, body) { | |
| if (response.statusCode == 200) { | |
| if (callback) { | |
| callback(JSON.parse(body).code); | |
| } | |
| } else { | |
| if (errorCallback) { | |
| errorCallback(response); | |
| } | |
| } | |
| }); | |
| }; | |
| exports.publish = function (code, apiName, apiToken, callback, errorCallback) { | |
| callback = callback || false; | |
| errorCallback = errorCallback || false; | |
| var body = { | |
| code: code, | |
| messageToSave: "Published from local repository" | |
| }; | |
| request({ | |
| method: 'POST', | |
| url: 'https://api.apiary.io/blueprint/publish/' + apiName, | |
| headers: getHeaders(apiToken, 'application/json'), | |
| body: JSON.stringify(body) | |
| }, function (error, response, body) { | |
| if (response.statusCode == 200 || response.statusCode == 201) { | |
| if (callback) { | |
| callback(response, body); | |
| } | |
| } else { | |
| if (errorCallback) { | |
| errorCallback(response, body); | |
| } | |
| } | |
| }); | |
| }; | |
| }).call(this); | |