forked from occlum/occlum
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrest_api.py
More file actions
executable file
·33 lines (23 loc) · 802 Bytes
/
rest_api.py
File metadata and controls
executable file
·33 lines (23 loc) · 802 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
#!/usr/bin/python3
import sys
import os
from flask import Flask, request
from flask_restful import Resource, Api
sys.path.insert(0, os.path.dirname(__file__))
cert = '/etc/flask.crt'
cert_key = '/etc/flask.key'
app = Flask(__name__)
api = Api(app)
customers = {}
class Customer(Resource):
def get(self, customer_id):
return {customer_id: customers[customer_id]}
def put(self, customer_id):
customers[customer_id] = request.form['data']
return {customer_id: customers[customer_id]}
api.add_resource(Customer, '/customer/<string:customer_id>')
if __name__ == '__main__':
app.debug = False
ssl_context = (cert, cert_key)
app.run(host='0.0.0.0', port=4996, threaded=True, ssl_context=ssl_context)
#app.run(host='0.0.0.0', port=4996, threaded=True)