Skip to content

Commit 48711ad

Browse files
committed
fix some response bodies
1 parent fece929 commit 48711ad

7 files changed

Lines changed: 40 additions & 6 deletions

File tree

surftimer/ck_bonus.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ def insertBonus(
6666
if xquery < 1:
6767
response.body = response.body = json.dumps(content_data).encode('utf-8')
6868
response.status_code = status.HTTP_304_NOT_MODIFIED
69+
response.headers['content-type'] = 'application/json'
6970
return response
7071

7172
# Prepare the response
@@ -74,6 +75,7 @@ def insertBonus(
7475

7576
response.body = response.body = json.dumps(content_data).encode('utf-8')
7677
response.status_code = status.HTTP_201_CREATED
78+
response.headers['content-type'] = 'application/json'
7779
return response
7880

7981
@router.put(
@@ -104,6 +106,7 @@ def updateBonus(
104106
content_data = {"updated": xquery, "xtime": time.perf_counter() - tic}
105107
if xquery < 1:
106108
response.body = json.dumps(content_data).encode('utf-8')
109+
response.headers['content-type'] = 'application/json'
107110
response.status_code = status.HTTP_304_NOT_MODIFIED
108111
return response
109112

@@ -112,6 +115,7 @@ def updateBonus(
112115
print(f"Execution time {toc - tic:0.4f}")
113116

114117
response.body = json.dumps(content_data).encode('utf-8')
118+
response.headers['content-type'] = 'application/json'
115119
response.status_code = status.HTTP_200_OK
116120
return response
117121

@@ -389,12 +393,14 @@ def deleteBonus(
389393
content_data = {"deleted": xquery, "xtime": time.perf_counter() - tic}
390394
if xquery < 1:
391395
response.body = json.dumps(content_data).encode('utf-8')
396+
response.headers['content-type'] = 'application/json'
392397
response.status_code = status.HTTP_304_NOT_MODIFIED
393398
return response
394399

395400
toc = time.perf_counter()
396401
print(f"Execution time {toc - tic:0.4f}")
397402

398403
response.body = json.dumps(content_data).encode('utf-8')
404+
response.headers['content-type'] = 'application/json'
399405
response.status_code = status.HTTP_200_OK
400406
return response

surftimer/ck_checkpoints.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class PlayerCheckpoints(BaseModel):
2323

2424
# ck_checkpoints
2525
@router.post(
26-
"surftimer/insertOrUpdateCheckpoints",
26+
"/surftimer/insertOrUpdateCheckpoints",
2727
name="Insert or Update Checkpoints",
2828
tags=["ck_checkpoints"],
2929
)
@@ -51,6 +51,7 @@ async def insertOrUpdateCheckpoints(
5151

5252
if xquery < 1:
5353
response.body = json.dumps(content_data).encode('utf-8')
54+
response.headers['content-type'] = 'application/json'
5455
response.status_code = status.HTTP_304_NOT_MODIFIED
5556
return response
5657

@@ -210,13 +211,15 @@ async def deleteCheckpoints(
210211
content_data = {"deleted": xquery, "xtime": time.perf_counter() - tic}
211212
if xquery < 1:
212213
response.body = json.dumps(content_data).encode('utf-8')
214+
response.headers['content-type'] = 'application/json'
213215
response.status_code = status.HTTP_304_NOT_MODIFIED
214216
return response
215217

216218
toc = time.perf_counter()
217219
print(f"Execution time {toc - tic:0.4f}")
218220

219221
response.body = json.dumps(content_data).encode('utf-8')
222+
response.headers['content-type'] = 'application/json'
220223
response.status_code = status.HTTP_200_OK
221224
return response
222225

surftimer/ck_latestrecords.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ async def insertLatestRecord(
8080
content_data = {"inserted": xquery, "xtime": time.perf_counter() - tic}
8181
if xquery < 1:
8282
response.body = json.dumps(content_data).encode('utf-8')
83+
response.headers['content-type'] = 'application/json'
8384
response.status_code = status.HTTP_304_NOT_MODIFIED
8485
return response
8586

surftimer/ck_maptier.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ async def insertMapTier(
7777
content_data = {"inserted": xquery, "xtime": time.perf_counter() - tic}
7878
if xquery < 1:
7979
response.body = json.dumps(content_data).encode('utf-8')
80+
response.headers['content-type'] = 'application/json'
8081
response.status_code = status.HTTP_304_NOT_MODIFIED
8182
return response
8283

@@ -109,6 +110,7 @@ async def updateMapTier(
109110
content_data = {"updated": xquery, "xtime": time.perf_counter() - tic}
110111
if xquery < 1:
111112
response.body = json.dumps(content_data).encode('utf-8')
113+
response.headers['content-type'] = 'application/json'
112114
response.status_code = status.HTTP_304_NOT_MODIFIED
113115
return response
114116

@@ -117,6 +119,7 @@ async def updateMapTier(
117119
print(f"Execution time {toc - tic:0.4f}")
118120

119121
response.body = json.dumps(content_data).encode('utf-8')
122+
response.headers['content-type'] = 'application/json'
120123
response.status_code = status.HTTP_200_OK
121124
return response
122125

@@ -140,6 +143,7 @@ async def updateMapperName(
140143
content_data = {"updated": xquery, "xtime": time.perf_counter() - tic}
141144
if xquery < 1:
142145
response.body = json.dumps(content_data).encode('utf-8')
146+
response.headers['content-type'] = 'application/json'
143147
response.status_code = status.HTTP_304_NOT_MODIFIED
144148
return response
145149

@@ -148,5 +152,6 @@ async def updateMapperName(
148152
print(f"Execution time {toc - tic:0.4f}")
149153

150154
response.body = json.dumps(content_data).encode('utf-8')
155+
response.headers['content-type'] = 'application/json'
151156
response.status_code = status.HTTP_200_OK
152157
return response

surftimer/ck_playeroptions2.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ async def insertPlayerOptions(request: Request, response: Response, steamid32: s
6666
content_data = {"inserted": xquery, "xtime": time.perf_counter() - tic}
6767
if xquery < 1:
6868
response.body = json.dumps(content_data).encode('utf-8')
69+
response.headers['content-type'] = 'application/json'
6970
response.status_code = status.HTTP_304_NOT_MODIFIED
7071
return response
7172

@@ -168,6 +169,7 @@ async def updatePlayerOptions(
168169
content_data = {"updated": xquery, "xtime": time.perf_counter() - tic}
169170
if xquery < 1:
170171
response.body = json.dumps(content_data).encode('utf-8')
172+
response.headers['content-type'] = 'application/json'
171173
response.status_code = status.HTTP_304_NOT_MODIFIED
172174
# response.headers['content-type'] = 'application/json'
173175

@@ -176,5 +178,6 @@ async def updatePlayerOptions(
176178
print(f"Execution time {toc - tic:0.4f}")
177179

178180
response.body = json.dumps(content_data).encode('utf-8')
181+
response.headers['content-type'] = 'application/json'
179182
response.status_code = status.HTTP_200_OK
180183
return response

surftimer/ck_playerrank.py

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class UpdatePlayerPoints(BaseModel):
3737

3838
# ck_playerrank
3939
@router.post(
40-
"surftimer/insertPlayerRank",
40+
"/surftimer/insertPlayerRank",
4141
name="Add Player Rank",
4242
tags=["ck_playerrank"],
4343
)
@@ -70,7 +70,9 @@ async def insertPlayerRank(
7070
content_data = {"inserted": xquery, "xtime": time.perf_counter() - tic}
7171
if xquery < 1:
7272
response.body = json.dumps(content_data).encode('utf-8')
73+
response.headers['content-type'] = 'application/json'
7374
response.status_code = status.HTTP_304_NOT_MODIFIED
75+
response.headers['content-type'] = 'application/json'
7476
return response
7577

7678
# Prepare the response
@@ -79,10 +81,11 @@ async def insertPlayerRank(
7981

8082
response.body = json.dumps(content_data).encode('utf-8')
8183
response.status_code = status.HTTP_201_CREATED
84+
response.headers['content-type'] = 'application/json'
8285
return response
8386

8487
@router.put(
85-
"surftimer/updatePlayerRankPoints",
88+
"/surftimer/updatePlayerRankPoints",
8689
name="Update Player Rank Points 1",
8790
tags=["ck_playerrank"],
8891
)
@@ -119,6 +122,7 @@ async def updatePlayerRankPoints(
119122
content_data = {"updated": xquery, "xtime": time.perf_counter() - tic}
120123
if xquery < 1:
121124
response.body = json.dumps(content_data).encode('utf-8')
125+
response.headers['content-type'] = 'application/json'
122126
response.status_code = status.HTTP_304_NOT_MODIFIED
123127
return response
124128

@@ -127,11 +131,12 @@ async def updatePlayerRankPoints(
127131
print(f"Execution time {toc - tic:0.4f}")
128132

129133
response.body = json.dumps(content_data).encode('utf-8')
134+
response.headers['content-type'] = 'application/json'
130135
response.status_code = status.HTTP_200_OK
131136
return response
132137

133138
@router.put(
134-
"surftimer/updatePlayerRankPoints2",
139+
"/surftimer/updatePlayerRankPoints2",
135140
name="Update Player Rank Points 2",
136141
tags=["ck_playerrank"],
137142
)
@@ -171,6 +176,7 @@ async def updatePlayerRankPoints2(
171176
content_data = {"updated": xquery, "xtime": time.perf_counter() - tic}
172177
if xquery < 1:
173178
response.body = json.dumps(content_data).encode('utf-8')
179+
response.headers['content-type'] = 'application/json'
174180
response.status_code = status.HTTP_304_NOT_MODIFIED
175181
return response
176182

@@ -179,11 +185,12 @@ async def updatePlayerRankPoints2(
179185
print(f"Execution time {toc - tic:0.4f}")
180186

181187
response.body = json.dumps(content_data).encode('utf-8')
188+
response.headers['content-type'] = 'application/json'
182189
response.status_code = status.HTTP_200_OK
183190
return response
184191

185192
@router.put(
186-
"surftimer/updatePlayerRank",
193+
"/surftimer/updatePlayerRank",
187194
name="Update Player Rank",
188195
tags=["ck_playerrank"],
189196
)
@@ -208,6 +215,7 @@ async def updatePlayerRank(
208215
content_data = {"updated": xquery, "xtime": time.perf_counter() - tic}
209216
if xquery < 1:
210217
response.body = json.dumps(content_data).encode('utf-8')
218+
response.headers['content-type'] = 'application/json'
211219
response.status_code = status.HTTP_304_NOT_MODIFIED
212220
return response
213221

@@ -216,6 +224,7 @@ async def updatePlayerRank(
216224
print(f"Execution time {toc - tic:0.4f}")
217225

218226
response.body = json.dumps(content_data).encode('utf-8')
227+
response.headers['content-type'] = 'application/json'
219228
response.status_code = status.HTTP_200_OK
220229
return response
221230

@@ -261,7 +270,7 @@ async def selectPlayerName(
261270

262271

263272
@router.put(
264-
"surftimer/updateLastSeenMySQL",
273+
"/surftimer/updateLastSeenMySQL",
265274
name="Update Last Seen",
266275
tags=["ck_playerrank"],
267276
)
@@ -278,6 +287,7 @@ async def updateLastSeen(
278287
content_data = {"updated": xquery, "xtime": time.perf_counter() - tic}
279288
if xquery < 1:
280289
response.body = json.dumps(content_data).encode('utf-8')
290+
response.headers['content-type'] = 'application/json'
281291
response.status_code = status.HTTP_304_NOT_MODIFIED
282292
return response
283293

@@ -286,6 +296,7 @@ async def updateLastSeen(
286296
print(f"Execution time {toc - tic:0.4f}")
287297

288298
response.body = json.dumps(content_data).encode('utf-8')
299+
response.headers['content-type'] = 'application/json'
289300
response.status_code = status.HTTP_200_OK
290301
return response
291302

surftimer/ck_playertemp.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ async def insertPlayerTmp(request: Request, response: Response, data: PlayerTemp
5656
content_data = {"inserted": xquery, "xtime": time.perf_counter() - tic}
5757
if xquery < 1:
5858
response.body = json.dumps(content_data).encode('utf-8')
59+
response.headers['content-type'] = 'application/json'
5960
response.status_code = status.HTTP_304_NOT_MODIFIED
6061
return response
6162

@@ -98,6 +99,7 @@ async def updatePlayerTmp(request: Request, response: Response, data: PlayerTemp
9899
content_data = {"updated": xquery, "xtime": time.perf_counter() - tic}
99100
if xquery < 1:
100101
response.body = json.dumps(content_data).encode('utf-8')
102+
response.headers['content-type'] = 'application/json'
101103
response.status_code = status.HTTP_304_NOT_MODIFIED
102104
return response
103105

@@ -106,6 +108,7 @@ async def updatePlayerTmp(request: Request, response: Response, data: PlayerTemp
106108
print(f"Execution time {toc - tic:0.4f}")
107109

108110
response.body = json.dumps(content_data).encode('utf-8')
111+
response.headers['content-type'] = 'application/json'
109112
response.status_code = status.HTTP_200_OK
110113
return response
111114

@@ -127,13 +130,15 @@ async def deletePlayerTmp(
127130
content_data = {"deleted": xquery, "xtime": time.perf_counter() - tic}
128131
if xquery < 1:
129132
response.body = json.dumps(content_data).encode('utf-8')
133+
response.headers['content-type'] = 'application/json'
130134
response.status_code = status.HTTP_304_NOT_MODIFIED
131135
return response
132136

133137
toc = time.perf_counter()
134138
print(f"Execution time {toc - tic:0.4f}")
135139

136140
response.body = json.dumps(content_data).encode('utf-8')
141+
response.headers['content-type'] = 'application/json'
137142
response.status_code = status.HTTP_200_OK
138143
return response
139144

0 commit comments

Comments
 (0)