from the web application to how can I run the Python script in the Ubuntu terminal?

0

Is there a way to run the python script terminal and get the output EC2 instance?

As an example, I get two values from the web app as input. With these two values as arguments, a Python script runs on the terminal.

Python3 add.py value1 value2
  1. What AWS services are required?
  2. Is there a way to get these values to be sent to a web application?
  3. What is the best way to run or trigger the Python script on the EC2 instance from the web app?

It's challenging for me to figure this out.

1개 답변
0

If I understand your question correctly: You have a web application and you want to send two values to a Python script; have it perform some operation and return a result.

While you could do this with EC2 I wouldn't recommend it - you would have a whole instance running all the time even when your web application isn't requesting any results.

Instead, consider using Lambda. Create a Lambda function using Python then publish that function using Lambda function URLs - you pass the two values to the URL and it executes the Lambda function, returning the appropriate value.

profile pictureAWS
전문가
답변함 2년 전
  • Brettski, I know it's not recommended for simple tasks, but the actual application is image processing.

    The S3 bucket folder name is the argument value. It takes a minimum of two to three hours to complete.

    I have tested the script manually and it works well. I want to automate it on the EC2 instance

    Thanks

  • Thanks for expanding on the question. In that case, I would use SQS: Send the job details to a SQS queue; have EC2 instances scale based on the length of the queue (that way you can run zero instances when there are no jobs; and you can scale to more instances if necessary); then your script on the EC2 instances reads the job details from the SQS queue. Don't forget to set the message visibility timeout to several hours. Note that you can create the SQS message as a trigger from S3 when the object is uploaded.

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠