node.js command line file excel on web server - javascript

My script in node.js generate a excel file, I need to put this file available on web server like web url and people can download it directly. Right now, script generate a excel file and it is available in windows folder. Thanks

If you really want to use nodejs for this you can use something like "static-server" and create a server that will export everything from you'r folder to the "web"..
But much better approach is to do it throught nginx or apache.
You can google with keywords "static [file] server (nginx|apache|nodejs)".

Related

Downloading XLS from URL

I'm trying to pull data, using an Ubuntu 16.04LTS server, from a website that uses JavaScript to export data into an XLS file.
https://www.adfg.alaska.gov/sf/FishCounts/index.cfm?ADFG=main.displayResults
Has a link called Export as Excel Spreadsheet
which gives you this link here
https://www.adfg.alaska.gov/sf/FishCounts/index.cfm?ADFG=export.excel&countLocationID=40&year=2017&speciesID=420
I tried using the command user$ wget rhino -weblink-
but it compiles with errors 79 Errors.
I don't know very much about programming, I'm just trying to automatically pull the data on a daily basis, and run a BASH script that calculates data from the spreadsheet for me.
Norrin
That URL worked properly without JS execution.
Here is the command that I use:
curl -L -o FishCount.xls 'https://www.adfg.alaska.gov/sf/FishCounts/index.cfm?ADFG=export.excel&countLocationID=40&year=2017&speciesID=420'
Be careful that use the single-quote to wrap URL. Otherwise BASH/SHELL will misinterpret & as background process.

Node.js or Ubuntu Linux run cron on server start up

So I have a node server on Ubuntu and I want it to
unzip a file that gets uploaded from ftp,
read a text file inside, and then
save the information to mongodb every day at 4am.
I'm a bit confused on whether I should let ubuntu do that or have my node server do that because I feel like this is a little bit of both: unzipping files to folder is easier with bash and reading and saving to mongodb is easier with javascript (for me).
Any suggestion on how I can approach this?
If you use https://github.com/EvanOxfeld/node-unzip you can get the file and data from the zip file, then use node to save it.
Though you could also probably use both, use bash to unzip and get the file name then send it as a parameter to the node file and run it, all through bash.

Run jar file with node js on Microsoft Azure

I make a node js web app for generating report. My idea is to use .jasper file (jasper report) to generate these reports. I've tried a bunch of node js library to do this, but nothing seems to work. And finally I proceed to make a .jar file (java) to solve this. The process is as follows:
Node js get request from user
Node js run .jar file by using child_process. It run something like "java -jar MyApp.jar arg1 arg2 arg3"
.jar file generate a pdf and save it to a folder
.jar file return the path of newly generated pdf file
Node js get the path and return pdf file to user
It run perfectly in my computer. Then I upload it to Microsoft Azure. It seems like the run .jar file step is failed, because no pdf file is created. Can anyone help me or suggest a better way to do this?
If you deployed the NodeJS webapp into MS Azure WebApps, the step 2 of the process could not spawn a child process for running a jar runnable file because the Java runtime environment not included your current Azure WebApp with NodeJS.
There are three suggested way to do this:
Using Azure VM to install NodeJS and Java, and deploy your app on the VM as the same as on the local computer. It's the simple way.
I searched an open source report software called jsreport. It can be install on MS Azure VM or Cloud Service. You can refer to the download page Run jar file with node js on Microsoft Azure to install it. And there is the jsreport sdk for NodeJS http://jsreport.net/learn/nodejs. If you want to use jsreport on Azure Cloud Service, you need to know how to build NodeJS App on Azure Cloud Service https://azure.microsoft.com/en-us/documentation/articles/cloud-services-nodejs-develop-deploy-express-app/.
Changing your process. NodeJS get request from user and send it with the specified file name and path to the ServiceBus; The jar runnable file modified as a Azure WebJob read the request from the ServiceBus and generate a pdf with the given file name and save it to the given file path on the Azure Blob Storage; NodeJS directly return pdf file to user from Blob Storage.
For Azure WebJob & Service Bus, you can refer to https://azure.microsoft.com/en-us/documentation/articles/web-sites-create-web-jobs/ and https://azure.microsoft.com/en-us/documentation/articles/service-bus-nodejs-how-to-use-queues/.
I suspect that your Java PDF generation calls into APIs restricted by the App Service sandbox. Most PDF rendering engines use GDI+, which has most functionality restricted by the Azure App Service sandbox. However, this policy is relaxed on dedicated servers. Scaling up to a dedicated server should resolve this problem (i.e. not the Shared or Free SKU).

Divide Meteor files into client and server folders

I'm writing a program with meteor and I'm wondering how one would go about splitting a single meteor JavaScript file, like one that is generated upon the 'meteor' command, into a client and server folder (client.js, server.js, etc). I haven't found any good guides. Does anybody know of any?
Thanks
Just create two directories, client and server. Then put the frontend codes in client and the backend codes in server. Take a look at http://docs.meteor.com/#structuringyourapp

Running a local server with javascript

I want to create a simple Javascript program with a HTML interface. The program will run in Chrome. I will also use node-serialport and Node.js to comunicate with an Arduino. I have a HTML and JavaScript file done, but I have no clue how to run it, or how to implement Node.js or node-serialport, nor how to "start" the sever. Initially it will only be running locally, but eventually it may become a real sever. For now, how do I run all that locally?
EDIT: I'm using the sample code from http://brandontilley.com/2012/03/02/controlling-an-arduino-from-nodejs.html, with the CoffeeScript converted into JavaScript.
Lucas, glad you found the blog post useful; perhaps I should add this information to it.
Getting the sketch into your Arduino
Just fire up the Arduino application, paste in the sketch code, and hit "Upload." Should be all you need to do here.
Starting the Node.js Server
What operating system are you using this on? Finding out how to access your Arduino microcontroller via node-serialport will differ based on your OS.
In the source code, change the string value of port to be your Arduino's device (once you know it). Also, the script depends on Express and (of course) node-serialport from NPM, so run npm install express serialport in the directory where your JavaScript file is saved. Finally, run the file with node server.js (assuming server.js is the name of your file). Then you can access the server at http://localhost:8080.
You can use node.js to serve up HTML with Express. If your main Javascript file is called server.js, then run it by typing:
node server.js
at the command line.

Categories

Resources