a. As mentioned above, the URL to get will be given in a double-quoted string as argv[1]. Therefore, the first step is to remove the double-quotes.
b. Have your program ignore Ctrl-C (SIGINT). You do not have to do this, but Ctrl-C is the way to stop simpleHttpServer.
If you do not ignore it then when you press Ctrl-C to stop the webserver, it will also get passed along to your program too. That will stop it.
Then when the webserver sends:
{“command”:”quit”}
your program will not be around to read() it. This will make the webserver upset. It will say:
Fine! No input for you!
c. Execute the HTTP call to get the JSON. Keep the data.
d. Enter a loop where you will get instructions in JSON from its standard input.
1. If the instruction your program gets is
{“command”:”quit”}
then to its standard output it should write:
{“status”:”quitting”}
and then stop the program.
2. If the instruction your program gets is like:
{“command”:”plot”,”xAxis”:”pl_orbper”,”yAxis”:”pl_orbeccen”}
then to its standard output it should create the desired graph.
Get the values for JSON variables “xAxis” and “yAxis”. Make the corresponding graph.
how to do that?
Personally, I recommend that you use gnuplot because it is already loaded on my system.
Open a data file (I called mine ./data.txt. To this data file write all x-axis and y-axis value pairs where both values are given. (If one or both values are null then do not bother writing them!)
Write a file that is a small program for gnuplot. I called mine scatter.gnu and its contents where:
set term png size 640,480
set output “scatterPlot.png”
set title “pl_orbeccen as a fnc of pl_orbper”
plot “./data.txt” with points pt 1
quit
gnuplot seems to like the size width: 640, height: 480, but feel free to play with those dimensions if you have the time.
Notice I have the x- and y-axis names in the title
fork() a child process to run /usr/bin/gnuplot. Pass the name of your gnuplot program (for me it is “scatter.gnu”) as an argument. Of course, have the parent wait() for the child.
Send JSON back to the webserver by writing to standard output. I found I had better results when I multiplied both the height and width by 3/4: {“status”:”success”,”imageFilename”:”scatterPlot.png”,”height”:360,”width”:480}
Delivering a high-quality product at a reasonable price is not enough anymore.
That’s why we have developed 5 beneficial guarantees that will make your experience with our service enjoyable, easy, and safe.
You have to be 100% sure of the quality of your product to give a money-back guarantee. This describes us perfectly. Make sure that this guarantee is totally transparent.
Read moreEach paper is composed from scratch, according to your instructions. It is then checked by our plagiarism-detection software. There is no gap where plagiarism could squeeze in.
Read moreThanks to our free revisions, there is no way for you to be unsatisfied. We will work on your paper until you are completely happy with the result.
Read moreYour email is safe, as we store it according to international data protection rules. Your bank details are secure, as we use only reliable payment systems.
Read moreBy sending us your money, you buy the service we provide. Check out our terms and conditions if you prefer business talks to be laid out in official language.
Read more