-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathserver.py
More file actions
30 lines (25 loc) · 869 Bytes
/
Copy pathserver.py
File metadata and controls
30 lines (25 loc) · 869 Bytes
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
from aiohttp import web
import asyncio, logging, aiohttp, traceback
#from configs import URL
URL = ""
r = web.RouteTableDef()
@r.get("/", allow_head=True)
async def root_route_handler(request):
return web.json_response("I am Alive")
async def web_server():
wap = web.Application(client_max_size=30000000)
wap.add_routes(r)
return wap
async def ping_server():
while True:
await asyncio.sleep(600)
try:
async with aiohttp.ClientSession(
timeout=aiohttp.ClientTimeout(total=10)
) as session:
async with session.get(URL) as resp:
logging.info("Pinged server with response: {}".format(resp.status))
except TimeoutError:
logging.warning("Couldn't connect to the site URL..!")
except Exception:
traceback.print_exc()