-
Notifications
You must be signed in to change notification settings - Fork 0
/
service2.py
64 lines (49 loc) · 1.69 KB
/
service2.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
from flask import Flask
from flask import request, render_template
import os
import requests
import socket
import sys
import mysql.connector
app = Flask(__name__)
TRACE_HEADERS_TO_PROPAGATE = [
'X-Ot-Span-Context',
'X-Request-Id',
# Zipkin headers
'X-B3-TraceId',
'X-B3-SpanId',
'X-B3-ParentSpanId',
'X-B3-Sampled',
'X-B3-Flags',
# Jaeger header (for native client)
"uber-trace-id",
# SkyWalking headers.
"sw8"
]
class Reservation:
def __init__(self, cel):
self.cel = cel
reservationArray = []
@app.route('/service/<service_number>', methods=['POST','GET'])
def hello(service_number):
if request.method =='POST':
app.logger.info(request.values['phone-number'])
reservation = Reservation(request.values['phone-number'])
# build connection to mysql
db = mysql.connector.connect(host="mysql-server", user="root", password="secret", database="ds_prj")
cursor = db.cursor()
query = "SELECT * FROM ticket_order WHERE phone_num = %s"
data = reservation.cel
cursor.execute(query, (data,))
ticket_info = cursor.fetchall()
db.commit()
app.logger.info(ticket_info)
cursor.close()
db.close()
if ticket_info:
return render_template('index2.html', result = ticket_info)
else:
return render_template('index2.html', result = None)
return render_template('index2.html', result = "")
if __name__ == "__main__":
app.run(host='127.0.0.1', port=8080, debug=True)