Skip to content

Commit f1134d6

Browse files
committed
add python
1 parent 39f0252 commit f1134d6

File tree

4 files changed

+53
-0
lines changed

4 files changed

+53
-0
lines changed

aiohttp-app/app.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
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)

aiohttp-app/runIt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
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)) &

flask-app/app.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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!"

flask-app/runIt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
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)) &

0 commit comments

Comments
 (0)