Skip to content

Instantly share code, notes, and snippets.

@ziplus4
ziplus4 / db_bind_sharding.py
Created December 16, 2015 06:42
flask, sqlalchemy sample : sharding
# -*- coding:utf8 -*-
import re
from flask import Flask
from flask_sqlalchemy import SQLAlchemy as BaseSQLAlchemy
from flask_sqlalchemy import _SignallingSession as BaseSignallingSession
from flask_sqlalchemy import orm, partial, get_state
from datetime import datetime
@ziplus4
ziplus4 / db_bind_replication.py
Created December 16, 2015 06:39
flask, sqlalchemy sample : database master, slave replication
# -*- coding:utf8 -*-
import re
from flask import Flask
from flask_sqlalchemy import SQLAlchemy as BaseSQLAlchemy
from flask_sqlalchemy import SignallingSession as BaseSignallingSession
from flask_sqlalchemy import orm, partial, get_state
from datetime import datetime
@ziplus4
ziplus4 / mysite_uwsgi.ini
Created October 23, 2015 05:02
uwsgi 설정 파일
# mysite_uwsgi.ini file
[uwsgi]
# Django-related settings
# the base directory (full path)
chdir = /path/to/your/project
# Django's wsgi file
module = project.wsgi
# the virtualenv (full path)
home = /path/to/virtualenv
@ziplus4
ziplus4 / mysite_nginx.conf
Created October 22, 2015 06:38
nginx와 django 연동을 위한 nginx 설정
# mysite_nginx.conf
# the upstream component nginx needs to connect to
upstream django {
# server unix:///path/to/your/mysite/mysite.sock; # for a file socket
server 127.0.0.1:8001; # for a web port socket (we'll use this first)
}
# configuration of the server
server {
@ziplus4
ziplus4 / test.py
Created October 22, 2015 06:24
uwsgi 테스트 코드
# test.py
def application(env, start_response):
start_response('200 OK', [('Content-Type','text/html')])
#return [b"Hello World"] # python3
return ["Hello World"] # python2