-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathserve.py
30 lines (24 loc) · 856 Bytes
/
serve.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
from flask import Flask, Response, jsonify
from json import dumps
import requests
import pdb
import importlib
app = Flask(__name__)
try:
app.config.from_envvar('DMF_CONFIG')
except RuntimeError:
app.config.from_object('config')
try:
SsnClient = getattr(importlib.import_module(app.config['SSN_MODULE']), app.config['SSN_CLIENT'])
except (ModuleNotFoundError, KeyError, AttributeError):
raise ImportError("Your SSN client backend couldn't be imported, probably because of an error with configuration.")
client = SsnClient(app.config)
@app.route('/')
def index():
return Response(status=200)
@app.route('/dmf/<ssn>')
def dmf_search(ssn):
dmf_record = client.get_dmf_record(ssn)
return Response(dumps(dmf_record), content_type="application/json")
if __name__ == '__main__':
app.run(host='0.0.0.0', debug=True, port=5001)