Skip to content

Instantly share code, notes, and snippets.

@rhamedy
Created April 18, 2021 21:45
Show Gist options
  • Save rhamedy/78b6d4c1720bc8c272d713b75ee85c8c to your computer and use it in GitHub Desktop.
Save rhamedy/78b6d4c1720bc8c272d713b75ee85c8c to your computer and use it in GitHub Desktop.
Sample Flask App - Ping Service
from flask import Flask
app = Flask(__name__)
import requests
@app.route('/')
def ping_service():
return 'Hello, I am ping service!'
@app.route('/ping')
def do_ping():
ping = 'Ping ...'
response = ''
try:
response = requests.get('http://pong-service-container:5001/pong')
except requests.exceptions.RequestException as e:
print('\n Cannot reach the pong service.')
return 'Ping ...\n'
return 'Ping ... ' + response.text + ' \n'
if __name__ == "__main__":
app.run(host ='0.0.0.0', port = 5000, debug = True)
FROM python:3.8-slim-buster
COPY . /app
WORKDIR /app
RUN pip install -r requirements.txt
ENTRYPOINT [ "python" ]
CMD [ "app.py" ]
Flask==0.12
requests==2.25.1
@sapbotgit
Copy link

Not work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment