Skip to content

Instantly share code, notes, and snippets.

version: '2'
services:
backend:
build: ./backend
ports:
- "9000:8000"
volumes:
- ../.:/app
FROM python:3.6.2
VOLUME ["/app"]
COPY start.sh /scripts/start.sh
WORKDIR /app/src
ENTRYPOINT ["/scripts/start.sh"]
#!/bin/bash
service ssh start
pip install --pre -U -r /app/src/.meta/packages
gunicorn app:app -c gunicorn.conf.py --reload
@rema7
rema7 / gunicorn.conf.py
Last active September 25, 2017 09:55
Gunicorn configuration file
# gunicorn.conf.py
import multiprocessing
bind = '0.0.0.0:8000'
workers = multiprocessing.cpu_count() * 2 + 1
timeout = 30
worker_connections = 1000
# middlewares.py
import json
class JSONEncoder(json.JSONEncoder):
def default(self, obj):
if isinstance(obj, bytes):
return obj.decode("utf-8")
return super(JSONEncoder, self).default(obj)
@rema7
rema7 / api.py
Last active September 25, 2017 10:48
Test REST Falcon resource file
# api.py
from datetime import datetime
class RestResource:
def on_get(self, _, resp):
resp.body = {
'result': 'Wow! Resul!:)',
'timestamp': datetime.utcnow(),
}
...
from middlewares import (
ContentEncodingMiddleware,
)
app = falcon.API(middleware=[
ContentEncodingMiddleware(),
])
# app.py
import falcon
from api.resources import (
RestResource,
)
from middlewares import (
ContentEncodingMiddleware,
)
ACCOUNTS_MAX_FRIENDS = 3
# FRONTEND URL SECTION
FURL_CONTACTS = '/api/contacts/'
FURL_PROFILE = '/api/profile/'
FURL_ACCOUNTS = '/api/accounts/<%= accountId %>'
# BACKEND SECTION
SETTINGS_ROUTE = '/settings'