Skip to content

Instantly share code, notes, and snippets.

@InFog
Created June 4, 2012 20:47
Show Gist options
  • Save InFog/2870786 to your computer and use it in GitHub Desktop.
Save InFog/2870786 to your computer and use it in GitHub Desktop.
WSGI com Bottle e VirtualEnv
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import sys
import site
current_path = os.path.abspath(os.path.dirname(__file__))
# check for python's version
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__))
import bottle
import myapp
application = bottle.default_app()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment