-
Notifications
You must be signed in to change notification settings - Fork 0
/
service3.py
56 lines (45 loc) · 1.73 KB
/
service3.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
from flask import Flask
from flask import request, render_template, redirect
import os
import requests
import socket
import sys
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, ticketName, ticketPrice, ticketDate):
self.ticketName = ticketName
self.ticketPrice = ticketPrice
self.ticketDate = ticketDate
reservationArray = []
@app.route('/service/<service_number>', methods=['POST','GET'])
def hello(service_number):
app.logger.info('method: {}'.format(request.method))
if request.method =='POST':
if request.values['book']=='More':
app.logger.info('ticketName: {}'.format(request.values['ticketName']))
app.logger.info('ticketPrice: {}'.format(request.values['ticketPrice']))
app.logger.info('ticketDate: {}'.format(request.values['ticketDate']))
reservation = Reservation(request.values['ticketName'], request.values['ticketPrice'], request.values['ticketDate'])
reservationArray.append(reservation)
return redirect('http://localhost:8080/service/4', code = "307")
else:
return render_template('index3.html',
service=os.environ['SERVICE_NAME'],
hostnameOne=socket.gethostname(),
hostnameTwo=socket.gethostbyname(socket.gethostname()))
if __name__ == "__main__":
app.run(host='127.0.0.1', port=8080, debug=True)