-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathapp.py
More file actions
executable file
·37 lines (31 loc) · 792 Bytes
/
app.py
File metadata and controls
executable file
·37 lines (31 loc) · 792 Bytes
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
from flask import Flask
from flask import request
from flask import json
from werkzeug.exceptions import HTTPException
app = Flask(__name__)
@app.route("/")
def ping_root():
return ping()
@app.route("/<string:path1>")
def ping_path1(path1):
return ping()
def ping():
return {
"host": request.host,
"url": request.url,
"method": request.method,
"message": "ping-api"
}
@app.errorhandler(HTTPException)
def handle_exception(e):
response = e.get_response()
response.data = json.dumps({
"code": e.code,
"name": e.name,
"description": e.description,
})
response.content_type = "application/json"
return response
if __name__ == '__main__':
app.debug = True
app.run(host='0.0.0.0', port=8000)