-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcore.py
42 lines (31 loc) · 1011 Bytes
/
core.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# Import OS to get environment variables
import os
# Get Flask and associated modules
from flask import Flask, request, render_template, jsonify
# Define the Flask app name from the filename
app = Flask(__name__)
# Get environment
env = os.environ.get('appenv', 'Development')
################
# Begin Routes #
################
# Root
@app.route('/')
def hello_world():
target = request.args.get('target', 'World')
return render_template('body.html',target=target,env=env)
# API Root
@app.route('/api/')
def api_world():
target = request.args.get('target', 'World')
return jsonify(target=target,environment=env)
# API Target
@app.route('/api/<target>')
def api_target(target):
return jsonify(target=target,environment=env)
##############
# End Routes #
##############
# Start development webserver on $PORT (or 8080 if environment variable not set) when file ran directly)
#if __name__ == "__main__":
# app.run(debug=True,host='0.0.0.0',port=int(os.environ.get('PORT', 8080)))