("type");
+ try { response.headers.set("access-control-allow-origin", "*"); } catch(e) {}
+ if (!file) throw new Error("File is required!");
+ var wb = read(file.content, {type: "buffer", dense: true});
+ return response.html( (type == "csv" ? utils.sheet_to_csv : utils.sheet_to_html)(wb.Sheets[wb.SheetNames[0]]));
+ }
+
+ public GET(request: Drash.Request, response: Drash.Response): void {
+ try { response.headers.set("access-control-allow-origin", "*"); } catch(e) {}
+ return response.html(`\
+
+
+
+ SheetJS Spreadsheet to HTML Conversion Service
+
+
+
+
+SheetJS Spreadsheet Conversion Service
+
+API
+
+Send a POST
request to https://s2c.sheetjs.com with the file in the file
body parameter:
+
+
+ curl -X POST -F"file=@pres.numbers" https://s2c.sheetjs.com/
+
+
+The response will be an HTML TABLE generated from the first worksheet.
+
+For CSV data, pass the parameter type=csv
:
+
+
+ curl -X POST -F"file=@pres.numbers" -F"type=csv" https://s2c.sheetjs.com/
+
+
+Try it out!
+
+
+
+SheetJS Library Version: ${version}
+
+
+`,
+ );
+ }
+}
+
+const server = new Drash.Server({
+ hostname: "",
+ port: 3000,
+ protocol: "http",
+ resources: [
+ SheetJSResource,
+ ],
+});
+
+server.run();
+
+console.log(`Server running at ${server.address}.`);
+