Skip to content

Instantly share code, notes, and snippets.

@InFog
Created June 12, 2012 19:26
Show Gist options
  • Save InFog/2919594 to your computer and use it in GitHub Desktop.
Save InFog/2919594 to your computer and use it in GitHub Desktop.
WSGI com Flask e VirtualEnv
#!/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