0

In my java code, I want to be able to call a URL and that URL should run my python script. Does anyone have a recommendation?

I have tried using Heroku to host the python script but I will also like an alternative

When I host my python code on my local server I can call the URL and the python script runs

But I want to be able to host the python script somewhere else so I can call the URL from my android app

1
  • Are you asking advices on python hosting services? Commented Jul 2, 2019 at 6:13

1 Answer 1

1

You need some kind of server to receive the request I have an example of flask here. A server-side code to receive and use the POST request using flask would look like this:

from flask import Flask, request
app = Flask(__name__)
@app.route('/', methods=['POST'])
def result():
    print(request.form['foo']) # should display 'bar'
    return 'Received !' # response to your request.

This is the simplest & quickest way to send/receive a POST request using python.

You can also use java to send the POST request.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks man. But where do i host it?. Its currently hosted on my localhost and when i try to call it from there it works perfectly. But how do i host it somewhere else so that i test with a live server and not my localhost

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.