As usual, to create an independent virtual environment, we need to install the virtualenv package in our global Python directory first, if we do not have this package yet. But, if we have been already installing the virtualenv package, we can create a virtual environment by opening the prompt window, cd to get into the folder for our blog engine, and write a statement as below:
virtualenv --always-copy myvenv
Next, to install Bottle.py web framework in our virtual environment, we need to activate it and use pip installer to install this framework.
myvenv\Scripts\activate pip install bottle
Each Bottle.py application, as well as Python application in general, needs a main module to run all codes in other modules that are hooked up to this module by the import statement. We can name this main module anything we like, but conventionally, web developers used to name it as "main.py".
#main.py from bottle import route, run @route('/') def main(): return "Hello World!" run(host='localhost', port=9000, debug=True, reloader=True)
To run the code in the module above, we could create a bat file by writing a number of commands as below:
call myvenv\Scripts\activate start http://localhost:9000 myvenv\Scripts\python main.py