-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
33 lines (26 loc) · 966 Bytes
/
app.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
# import flask framework
from flask import Flask, request
import requests
import json
# create a flask app instance
app = Flask(__name__)
# POST / handler
@app.route('/', methods=['POST'])
def orca_validation():
if request.method == 'POST':
data = request.get_json()
# debug purpose: show in console raw data received
print("Request received: \n"+json.dumps(data, sort_keys=True, indent=4))
# NOTE:
# orca system fields start with ___
# you can access the value of each field using the field name (data["Name"], data["Barcode"], data["Location"])
name = data["Name"]
# validation example
if(len(name) > 20):
# return json error message
return json.dumps({
"title": "Invalid Name",
"message": "Name cannot contain more than 20 characters",
})
# return HTTP Status 200 with no body
return '', 200