File tree Expand file tree Collapse file tree 1 file changed +12
-8
lines changed
frameworks/Python/aiohttp/app Expand file tree Collapse file tree 1 file changed +12
-8
lines changed Original file line number Diff line number Diff line change 1+ import platform
12from operator import attrgetter , itemgetter
23from pathlib import Path
34from random import randint , sample
45
56import jinja2
67from aiohttp .web import Response
7- from orjson import dumps
88from sqlalchemy import bindparam , select
99from sqlalchemy .orm .attributes import flag_modified
1010
1111from .models import Fortune , World
1212
13+ if platform .python_implementation () == "PyPy" :
14+ from aiohttp .web import json_response
15+ else :
16+ from orjson import dumps
17+
18+ def json_response (payload ):
19+ return Response (
20+ body = dumps (payload ),
21+ content_type = "application/json" ,
22+ )
23+
1324ADDITIONAL_FORTUNE_ORM = Fortune (id = 0 , message = 'Additional fortune added at request time.' )
1425ADDITIONAL_FORTUNE_ROW = {'id' : 0 , 'message' : 'Additional fortune added at request time.' }
1526READ_ROW_SQL = 'SELECT "randomnumber", "id" FROM "world" WHERE id = $1'
@@ -35,13 +46,6 @@ def get_num_queries(request):
3546 return num_queries
3647
3748
38- def json_response (payload ):
39- return Response (
40- body = dumps (payload ),
41- content_type = "application/json" ,
42- )
43-
44-
4549async def json (request ):
4650 """
4751 Test 1
You can’t perform that action at this time.
0 commit comments