-2

I have a C program that takes in input parameters and uses them to compute the trajectory of a particle. I want for this program to be hosted on my AWS EC2 server running linux, so that when someone loads a webpage loaded on the server they are able to input the parameters, run the C program on the server, and then see the results (images, plot with gnu plot etc..). I'm thinking of running a LAMP server but am unsure whether FLASK would be easier. Any help is appreciated. Running Apache.

1

You should look up what the CGI interface does. CGI means Common Gateway Interface here.

On your webserver, you could put your C program into a directory that has special permissions for the web server process. For instance, the directory must be enterable by the web server, and your C program must have execute permission for the "Others" group. Wrap your C program with a shell script if necessary.

CGI specifies how your webserver takes input data from the web user. Your webserver then calls your C program as a console script, collects the output from the C binary, and then sends that output back to the user.

CGI was used a lot in the 1990s, but it does not scale up to 100s of users, has difficulty with long-running processes and has security problems. Therefore it has fallen out of fashion in the 2000s.

But for, say, an inhouse application with a small set of users, CGI programs can still be used, and IMHO programming CGI scripts is a useful skill to have.

0

Lolx! Here's a direct quote from my answer to this question, where, coincidentally, @knb also advocated CGI.

To be honest, I think these day's it's just a matter of choice, with web assembly being the more modern. The deciding point is that if the code should run on the server, use CGI, if in the browser, use web assembly.


Quote:

You can do this using Web assembly.

See this page for browser support, which is fairly solid, except for Internet Explorer (which currently has only 2.82% market share and falling, so can be considered an edge case and discounted).

Read WebAssembly: How and why

How to run native code in the browser, why would you do that, and what does it all mean for JavaScript and the future of web development

Take a look at Get started with WebAssembly — using only 14 lines of JavaScript and DuckDuckGo further.

  • 1
    I've posted my previous answer to resurrect it from a closed question which is inaccessible to new users. – knb Jan 16 at 11:57
  • Upvote, and please don't think that I was criticising. I suspect that CGI is the simplest way to do it, and requires less bandwidth. We may as well make both options known though :-) – Mawg Jan 16 at 12:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.