-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
45 lines (40 loc) · 1.34 KB
/
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
33
34
35
36
37
38
39
40
41
42
43
44
45
from flask import Flask
import csv
import re
app = Flask(__name__)
@app.route("/api/customer/<telno>")
def customerbynumber(telno):
telno = re.sub('[^0-9]','', telno)
reader = csv.DictReader(open('data/caller_info.csv', 'r'), delimiter = ',', quotechar="\"")
for rec in reader:
value = rec['number']
if str(value) == str(telno):
return rec
return ('', 204)
@app.route("/api/car/<telno>")
def carbynumber(telno):
telno = re.sub('[^0-9]','', telno)
reader = csv.DictReader(open('data/car_numbers.csv', 'r'), delimiter = ',', quotechar="\"")
for rec in reader:
value = rec['number']
if str(value) == str(telno):
return rec
return ('', 204)
@app.route("/api/order/<telno>")
def order(telno):
telno = re.sub('[^0-9]','', telno)
reader = csv.DictReader(open('data/order.csv', 'r'), delimiter = ',', quotechar="\"")
for rec in reader:
value = rec['number']
if str(value) == str(telno):
return rec
return ('', 204)
@app.route("/api/purchase/<telno>")
def purchase(telno):
telno = re.sub('[^0-9]','', telno)
reader = csv.DictReader(open('data/caller_purchase.csv', 'r'), delimiter = ',', quotechar="\"")
for rec in reader:
value = rec['number']
if str(value) == str(telno):
return rec
return ('', 204)