Created
June 12, 2012 19:26
-
-
Save InFog/2919594 to your computer and use it in GitHub Desktop.
WSGI com Flask e VirtualEnv
This file contains hidden or 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
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
import os | |
import sys | |
import site | |
current_path = os.path.abspath(os.path.dirname(__file__)) | |
# sempre verifique a versão do Python no sistema | |
# pode ser que seja necessário mudar abaixo | |
vepath = "%s/venv/lib/python2.7/site-packages/" % current_path | |
prev_sys_path = list(sys.path) | |
site.addsitedir(vepath) | |
sys.path.append(current_path) | |
new_sys_path = [p for p in sys.path if p not in prev_sys_path] | |
for item in new_sys_path: | |
sys.path.remove(item) | |
sys.path[:0] = new_sys_path | |
os.chdir(os.path.dirname(__file__)) | |
from myapp import app as application |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment