-2

This is a beginner question. I post this here because I'm so lost that I realized I even don't know what to look for.

I'm a C++ developper and have a developed C++ app. On the other hand, I recently dug into web development and created a website using the Django framework, which I host on Heroku.

The flow of the website: a user enters input on the website, input files are uploaded to AWS S3 (I managed to get that working).

The part I'm lost: with the user input, I'd like to run the C++ app which I host on a Linux server (Codenvy). But I have no idea how to launch that application from the Django site which is served by Heroku. At least giving some keywords to enhance my web searches?

halfer
  • 19,824
  • 17
  • 99
  • 186
mfnx
  • 2,894
  • 1
  • 12
  • 28
  • Possible duplicate of [executable files and django](https://stackoverflow.com/questions/5681705/executable-files-and-django) – Swordfish Sep 27 '18 at 21:49
  • It's not clear how you would want to start the C++ app. Do you want it to respond to an HTTP request? If so, a simple web server and a queue might help. – halfer Sep 27 '18 at 22:07
  • @halfer Thanks. I think I want the server, where the website is, to send a request to the server where the C++ app is, which would than execute the app. – mfnx Sep 28 '18 at 06:12
  • 1
    OK, so you need to determine the format of that request. Is HTTP acceptable? If so, set up a simple listener on that server, with appropriate security in place to ensure only authorised people can trigger its execution. Then you can either run your C++ program inside that server (blocking the web process) or kick it off in a queue (which will run it outside of the web server context). – halfer Sep 28 '18 at 09:01
  • @halfer Thanks again. HTTP would be great. Keywords as "listener" help me a lot here. Would that be like building a REST service on the server? Sorry for being that noob in the matter. – mfnx Sep 28 '18 at 09:49
  • Yes, although it does not need to be RESTful (that would be extra unnecessary work). You can use any simple web server and a bit of script to run your C++ program on the console. The PHP built-in web server would be fine, or Flask, the Python microframework, or Django, or even a C-level socket listener. – halfer Sep 28 '18 at 10:29
  • @halfer ok, thanks a lot! – mfnx Sep 28 '18 at 10:41

1 Answers1

1

It sounds like what you need is to run a script on another server using python?

I'd suggest taking a look at Paramiko:

https://github.com/paramiko/paramiko/

It is a package to allow you to ssh into another machine and execute commands.

Adam Hopkins
  • 6,837
  • 6
  • 32
  • 52
  • Thanks, I'll try this out. Would it be possible maybe to access by means of an url instead of using ssh? I guess I need to figure out the best way to connect to a Codenvy machine. The ssh2 library paramiko sounds like a good option though! – mfnx Sep 28 '18 at 06:17
  • 1
    If that's the case.... then check out http://docs.python-requests.org/en/master/ – Adam Hopkins Sep 28 '18 at 06:19