The code below is really annoying me I have looked on stackoverflow and google yet have not found anything and I am a pretty good pyton programmer and have not as of yet, well untill now, found an error that I could not deal with. I have tried everything but this peace of code is giving me the IndentationError: unexpected unindent which is weird because the normal error is “undexpected indent” which means as posted many times that its the spacing and how I spaced it so I went through the whole code and nada same error and I put in four spaces correctly and everything still … nothing. help?
from bottle import Bottle, run, route, static_file, debug
from mako.template import Template as temp
from mako.lookup import TemplateLookup
lookup = TemplateLookup(directories=[base+'/templates'])
application = Bottle()
if __name__ == '__main__':
@route('/')
else:
@application.route('/')
def index():
index_temp = lookup.get_template('index.html')
return index_temp.render(site=site, corperate=corperate, copyright=copyright)
I think your idea is to have a different decorator apply to a function depending on whether the module is being run directly, or imported. Unfortunately this won’t work the way you have it, because the decorator call needs the function to follow immediately after it. However, you could do it like this:
Or, assuming you’re importing
applicationsomewhere, you could justfrom application import routeto begin with, and then you wouldn’t need anyifstatements.