Created
November 13, 2019 20:46
-
-
Save beratdogan/d06687b5043a42580d7beeba9dd0420a to your computer and use it in GitHub Desktop.
Playing with Bjoern + Falcon
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Build | |
docker build . -t asd | |
# Run | |
docker run -p 8000:8000 asd | |
# Bench | |
ab -c 130 -n 10000 http://localhost:8000/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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