File tree Expand file tree Collapse file tree 4 files changed +53
-0
lines changed
Expand file tree Collapse file tree 4 files changed +53
-0
lines changed Original file line number Diff line number Diff line change 1+ import asyncio
2+ from aiohttp import web
3+
4+
5+ def toInt (x ):
6+ try :
7+ return int (x )
8+ except Exception :
9+ return 0
10+
11+
12+ async def index (request ):
13+ delay = request .GET .get ('delay' )
14+ await asyncio .sleep (toInt (delay )/ 1000 )
15+ return web .Response (text = "Welcome home!" )
16+
17+
18+ app = web .Application ()
19+ app .router .add_get ('/' , index )
Original file line number Diff line number Diff line change 1+ python3 -m venv env
2+ env/bin/pip install wheel
3+ env/bin/pip install aiohttp==2.2.5 gunicorn==19.7
4+
5+ cores=`nproc`
6+ env/bin/gunicorn app:app -b 127.0.0.1:8080 --worker-class aiohttp.GunicornWebWorker -w $(($cores*2)) &
Original file line number Diff line number Diff line change 1+ import time
2+ from flask import (
3+ Flask ,
4+ request
5+ )
6+
7+
8+ app = Flask (__name__ )
9+
10+
11+ def toInt (x ):
12+ try :
13+ return int (x )
14+ except Exception :
15+ return 0
16+
17+
18+ @app .route ("/" )
19+ def hello ():
20+ delay = request .args .get ('delay' )
21+ time .sleep (toInt (delay )/ 1000 )
22+ return "Hello World!"
Original file line number Diff line number Diff line change 1+ python3 -m venv env
2+ env/bin/pip install wheel
3+ env/bin/pip install flask==0.12.2 gunicorn==19.7
4+
5+ cores=`nproc`
6+ env/bin/gunicorn app:app -b 127.0.0.1:8080 -w $(($cores*2)) &
You can’t perform that action at this time.
0 commit comments