· 5 years ago · Oct 28, 2020, 05:10 AM
1const rp = require("request-promise");
2const fs = require("fs");
3
4const key = "PCJwoD0rzUr8eJ6TOV_3Dm40wr_czPis";
5const api = "https://pastebin.com/api/api_post.php";
6
7//argv 0 is node, 1 is main,js 2 is path
8var filePath = process.argv[2];
9console.log(filePath);
10
11fs.readFile(filePath, async (err, data) => {
12 console.log(data);
13 const options = {
14 uri: api,
15 method: "POST",
16 headers: {
17 "Content-Type": "application/json;charset=UTF-8",
18 },
19 form: {
20 api_dev_key: key,
21 api_option: "paste",
22 api_paste_format: "cpp",
23 api_paste_code: data,
24 },
25 };
26
27 console.log(await rp(options));
28});
29