...
1from typing import Optional
2
3import sys
4import yaml
5
6from flask import Flask, jsonify, request
7
8app = Flask(__name__)
9
10@app.route('/api/snapshot/<generation_counter>/<kind>')
11def services(generation_counter, kind):
12 try:
13 with open(app.snapshot_path, 'r') as snapshot:
14 return snapshot.read(), 200
15 except Exception as e:
16 return "uhoh (%s)" % e, 500
17
18
19def main(snapshot_path: str):
20 app.snapshot_path = snapshot_path
21
22 print("serving on 9999 from %s" % snapshot_path)
23 app.run(host='0.0.0.0', port=9999, debug=True)
24
25
26if __name__ == '__main__':
27 snapshot_path = sys.argv[1]
28
29 main(snapshot_path)
View as plain text