Making a webapp using Bottle Here is a screenshot of my setup:



Here is the actual code:

#activate python virtualenv
activate_this = 'C:/Users/D/Dropbox/_mypyapp/learnbottle/learnbottle/scripts/activate_this.py'
execfile(activate_this, dict(__file__=activate_this))

#import dependencies
import os
from bottle import route, run, template

#this is what will become the page html
index_html = '''My First web app! By {{ author }}'''


@route('/:anything')
def something(anything = ''):
    return template(index_html, author = anything)
@route('/')
def index():
    return template(index_html, author = 'your name here')

if __name__ == '__main__':
    port = int(os.environ.get('PORT', 8080))
    run(host = '0.0.0.0', port = port, debut = True)


Couple things I should note:


This is my first time using virtualenv 
This is the first time I am using git 
This is my first time writing any sort of web app or using a framework


I'm following along with a tutorial on realpython.com. The tutorial is written for a "Unix-based environment" so I had to do some things to get it working on Windows. Not sure if I should go the route of setting up a VM as it seems unnecessarily complicated.

So, am I making any newbie mistakes and is there anything I should do differently?
Don't activate the virtualenv inside the script. If you do, the script won't be portable, it won't run on other computers, as that absolute path is specific to your computer. The virtualenv is part of the runtime execution environment, should not be part of the source code. Add a wrapper script that will activate the virtualenv and then run your app.




@route('/:anything')
def something(anything = ''):
    return template(index_html, author = anything)



I don't know bottle, but it seems to me that the default value setting anything = '' is pointless, because the path / should not match this route.



PEP8 dictates to put 2 empty lines before every global function declaration. So put 2 empty lines right before this code:


@route('/')
def index():
    return template(index_html, author = 'your name here')





This looks like a typo:


run(host = '0.0.0.0', port = port, debut = True)



You probably meant debug instead of "debut".