3.3 Case Studies of API Development
Key Points
- API development case (data processing)
Preparation Before Class
None.
Course Content
API Development Case (Data Processing)
from flask import Flask, request
import json
app = Flask(__name__)
@app.route('/test/', methods=['POST']) #Because Jodoo only accepts POST requests
def hello_world():
alldata = json.loads(request.data)
x = alldata['data']['x']
y = alldata['data']['y']
z = alldata['data']['z']
if x==10:
print(x*y*z)
return 'success',200
if __name__ == '__main__':
app.run(host='0.0.0.0',port=3100)