I have tested my python app for two different ports container1(5000) and container2(5100). It returns 'The requested URL was not found on this server'
container1 -> app.py
import flask
import requests
app = flask.Flask(__name__)
@app.route('/definition', methods=['POST'])
def gateKeeper():
request_data = flask.request.get_json()
text = request_data['text']
if text == None or len(text) == 0:
output = {
"text":text,
"error":"Invalid JSON input."
}
else:
wordToSend = {"text":text.strip().lower()}
res = requests.post('http://container2:5100/getDefinition', json=wordToSend)
output = res.json()
return output
if __name__=="__main__":
app.run(port=5000)
container2 -> app.py
import flask
app = flask.Flask(__name__)
@app.route('/getDefinition', methods=['POST'])
def gateKeeper():
request_data = flask.request.get_json()
text = request_data['text']
if text == None or len(text) == 0:
output = {
"text":text
"error":"Invalid JSON input."
}
else:
wordToSend = {"text":text.strip().lower()}
res = requests.post('http://localhost:5000/tests/endpoint', json=wordToSend)
output = res.json
return output
if __name__=="__main__":
app.run(port=5100)
Run this command for the run containers:
docker run -dit --name container1 -p 5000:80 httpd:2.4
docker run -dit --name container2 -p 5100:80 httpd:2.4