Skip to content

Instantly share code, notes, and snippets.

@beratdogan
Created November 13, 2019 20:46
Show Gist options
  • Save beratdogan/d06687b5043a42580d7beeba9dd0420a to your computer and use it in GitHub Desktop.
Save beratdogan/d06687b5043a42580d7beeba9dd0420a to your computer and use it in GitHub Desktop.
Playing with Bjoern + Falcon
# Build
docker build . -t asd
# Run
docker run -p 8000:8000 asd
# Bench
ab -c 130 -n 10000 http://localhost:8000/
from datetime import datetime
import time
import falcon
import bjoern
class TestResource:
def on_get(self, req, resp):
time.sleep(1)
resp.media = {"status": "ok", "time": datetime.now().isoformat()}
app = falcon.API()
app.add_route('/', TestResource())
bjoern.run(app, '0.0.0.0', 8000)
FROM python:3.7-alpine
RUN apk add --no-cache make build-base libev-dev
RUN pip install bjoern
RUN pip install falcon
WORKDIR /code
COPY app.py .
EXPOSE 8000
CMD python app.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment