2021-05-07 00:24:50 +00:00
|
|
|
import time
|
|
|
|
from flask import Flask
|
|
|
|
|
2021-06-21 22:58:08 +00:00
|
|
|
import os
|
|
|
|
|
2021-05-07 00:24:50 +00:00
|
|
|
app = Flask(__name__)
|
|
|
|
|
2021-06-21 22:58:08 +00:00
|
|
|
# Read environment variables
|
|
|
|
if "DEBUG" in os.environ and os.environ["DEBUG"] == 'yes':
|
|
|
|
debug = True
|
|
|
|
else:
|
|
|
|
debug = False
|
|
|
|
if "HOST" in os.environ:
|
|
|
|
host = os.environ["HOST"]
|
|
|
|
else:
|
|
|
|
host = '0.0.0.0'
|
|
|
|
if "PORT" in os.environ:
|
|
|
|
port = int(os.environ["PORT"])
|
|
|
|
else:
|
|
|
|
port = 5000
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@app.route('/')
|
|
|
|
def home():
|
|
|
|
return "Hello World"
|
|
|
|
|
2021-05-07 00:24:50 +00:00
|
|
|
@app.route('/time')
|
|
|
|
def get_current_time():
|
|
|
|
return {'time': time.time()}
|
2021-06-21 22:58:08 +00:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
app.run(debug=debug, host=host, port=port)
|