-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathstart.py
58 lines (39 loc) · 1.42 KB
/
start.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import logging
import os
from flask import Flask, make_response, render_template
from apps.globals import VERSION
from apps.root import output
from config import Config
app = Flask(__name__)
FMT = "[%(asctime)s] %(levelname)s [%(filename)s:%(lineno)d] [%(funcName)s] %(message)s"
LOGLEVEL = logging.INFO if os.environ.get("RUNMODE") == "production" else logging.DEBUG
logging.basicConfig(format=FMT, level=LOGLEVEL)
app.config.from_object(Config)
if app.config["RUNMODE"]:
app.logger.debug("Configuration set with RUNMODE=%s", app.config["RUNMODE"])
# ************************************************************************
# **************************** SERVICE ROUTES ****************************
# ************************************************************************
@app.route("/extent", methods=["GET", "POST"])
def extent():
return output()
@app.route("/query", methods=["GET", "POST"])
def query():
return output()
@app.route("/application.wadl")
def wadl():
template = render_template("wadl.xml")
response = make_response(template)
response.headers["Content-Type"] = "application/xml"
return response
@app.route("/version", strict_slashes=False)
def version():
response = make_response(VERSION)
response.headers["Content-Type"] = "text/plain"
return response
@app.route("/")
def doc():
return render_template("doc.html")
# **** MAIN ****
if __name__ == "__main__":
app.run()