This commit is contained in:
parent
7e040bb70a
commit
dae7bc720b
BIN
dist/app-1.0.0-py3-none-any.whl
vendored
BIN
dist/app-1.0.0-py3-none-any.whl
vendored
Binary file not shown.
BIN
dist/app-1.0.0.tar.gz
vendored
BIN
dist/app-1.0.0.tar.gz
vendored
Binary file not shown.
@ -38,7 +38,7 @@ class BaseApplication(web.Application):
|
|||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
|
|
||||||
def run(self, *args, **kwargs):
|
def run(self, *args, **kwargs):
|
||||||
web.run_app(self,*args,**kwargs)
|
web.run_app(self, *args, **kwargs)
|
||||||
|
|
||||||
async def authenticate(self, username, password):
|
async def authenticate(self, username, password):
|
||||||
return self.username == username and self.password == password
|
return self.username == username and self.password == password
|
||||||
@ -109,7 +109,7 @@ class WebDbApplication(BaseApplication):
|
|||||||
self.db_web = db_web
|
self.db_web = db_web
|
||||||
self.db_path = db_path
|
self.db_path = db_path
|
||||||
self.db = db or dataset.connect(self.db_path)
|
self.db = db or dataset.connect(self.db_path)
|
||||||
|
|
||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
if not self.db_web:
|
if not self.db_web:
|
||||||
return
|
return
|
||||||
@ -122,9 +122,9 @@ class WebDbApplication(BaseApplication):
|
|||||||
self.router.add_post("/db/get", self.get_handler)
|
self.router.add_post("/db/get", self.get_handler)
|
||||||
self.router.add_post("/db/set", self.set_handler)
|
self.router.add_post("/db/set", self.set_handler)
|
||||||
|
|
||||||
async def set_handler(self,request):
|
async def set_handler(self, request):
|
||||||
obj = await request.json()
|
obj = await request.json()
|
||||||
response = await self.set(obj.get("key"),obj.get("value"))
|
response = await self.set(obj.get("key"), obj.get("value"))
|
||||||
return web.json_response(response)
|
return web.json_response(response)
|
||||||
|
|
||||||
async def get_handler(self, request):
|
async def get_handler(self, request):
|
||||||
@ -153,7 +153,7 @@ class WebDbApplication(BaseApplication):
|
|||||||
|
|
||||||
async def find_handler(self, request):
|
async def find_handler(self, request):
|
||||||
obj = await request.json()
|
obj = await request.json()
|
||||||
response = await self.find(obj.get("table"), obj.get("where", {}))
|
response = await self.find(obj.get("table"), obj.get("where", {}))
|
||||||
return web.json_response(response)
|
return web.json_response(response)
|
||||||
|
|
||||||
async def find_one_handler(self, request):
|
async def find_one_handler(self, request):
|
||||||
|
@ -30,7 +30,7 @@ async def bench(url):
|
|||||||
while True:
|
while True:
|
||||||
index += 1
|
index += 1
|
||||||
try:
|
try:
|
||||||
async with session.get(url.rstrip("/") + "/stat") as response:
|
async with session.get(url.rstrip("/") + "/stat"):
|
||||||
pass
|
pass
|
||||||
time_end = time.time()
|
time_end = time.time()
|
||||||
duration = time_end - time_start
|
duration = time_end - time_start
|
||||||
@ -39,7 +39,10 @@ async def bench(url):
|
|||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
log.exception(ex)
|
log.exception(ex)
|
||||||
await asyncio.sleep(1)
|
await asyncio.sleep(1)
|
||||||
log.info("{} requests per second. Made {} requests in total in duration of {} seconds.".format(index/duration_limit,index,duration))
|
log.info(
|
||||||
|
f"{index / duration_limit} requests per second. Made {index} requests in total in duration of {duration} seconds."
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def cli_bench():
|
def cli_bench():
|
||||||
args = parse_args()
|
args = parse_args()
|
||||||
|
@ -2,15 +2,13 @@ from IPython.terminal.embed import InteractiveShellEmbed
|
|||||||
|
|
||||||
|
|
||||||
def repl(**kwargs):
|
def repl(**kwargs):
|
||||||
from .app import Application
|
|
||||||
variables = {}
|
variables = {}
|
||||||
variables.update(globals().copy())
|
variables.update(globals().copy())
|
||||||
variables.update(locals())
|
variables.update(locals())
|
||||||
variables.update(kwargs)
|
variables.update(kwargs)
|
||||||
|
|
||||||
shell = InteractiveShellEmbed(
|
shell = InteractiveShellEmbed(exit_msg="Exiting...")
|
||||||
exit_msg="Exiting..."
|
|
||||||
)
|
|
||||||
shell(local_ns=variables)
|
shell(local_ns=variables)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user