import web,re,traceback
urls=(
"/","displaythreads"
"/viewthread","displaythreads",
"/viewthread/(.*)","displaythread",
"/viewthread/(.*)/Vote/(Up|Down)","vote",
"/newthread/(.*)","newthread",
"/newthread","newthread"
)
entries={}###{entryname:{property:value}}
entrylength=0
class displaythreads:
    pass
class newthread:
    template=web.template.frender("newthread.html")
    default=template("DEFAULT",0)
    def initialize():
        pass
    def GET():
        return default
    def POST():
        data = web.input()
        try:
            username,threadname = data.username,data.threadname
        except:
            return template(mode)
        if threadname in entries:
            return template("Exists")
        entries[threadname]={"creator":username,"points":0,"totvotes":0}
class displaythread:
    template=web.template.frender('Thread Viewer Template.html')
    def initialize():
        pass
    def GET(self):
        return self.template(
            entrylength,
            entries.keys(),
            [value['name'] for value in entries.values()]

                      )
class vote:
    template=web.template.frender('vote.html')
    def initialize():
        pass
    def GET(self,thread,vote):
        try:
            current=web.cookies().get("Voted:"+thread)
        except:
            current="BEING DELETED" #act like it is being deleted if its not there.
        ######Set cookies and change votes#########
        ##Removing/Adding an extra vote if it was previously voted the other way##
        if vote=="Up":
            setcookie("Voted:"+thread,"up")
            if current=="down":
                entries[thread]["votes"]+=1
            entries[thread]["votes"]+=1
            id=0
        elif vote=="Down":
            setcookie("Voted:"+thread,"down")
            if current=="up":
                entries[thread]["votes"]-=1
            entries[thread]["votes"]-=1
            id=0
        elif vote=="Remove":
            if current=="up":
                entries[thread]["votes"]-=1
            elif current=="down":
                entries[thread]["votes"]+=1
            setcookie("Voted:"+thread,"BEING DELETED",expires=1)
            id=1
            if current != "BEING DELETED":# if he hasn't already voted, increase the total vote count by 1
                totvotes+=1
        return self.template(vote,id)
#classes = [eval(item) for item,number in enumerate(urls) if number%2==1]
#for i in classes:
    #i.initialize()
app = web.application(urls, globals())
if __name__ == "__main__":
    try:
        app.run()
    except:
        traceback.print_exc()
        input()

web.py latest version from gihub.
Macintosh python 2.7.6 32 bit
It's a forum.
12a0465434da395b02201ddd0667d28f

Edited 2 Years Ago by pyTony: Pasted screenshot for error

Attachments
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!-- saved from url=(0020)http://0.0.0.0:8080/ -->
<html lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  
  <meta name="robots" content="NONE,NOARCHIVE">
  <title>&lt;type 'exceptions.KeyError'&gt; at /</title>
  <style type="text/css">
    html * { padding:0; margin:0; }
    body * { padding:10px 20px; }
    body * * { padding:0; }
    body { font:small sans-serif; }
    body>div { border-bottom:1px solid #ddd; }
    h1 { font-weight:normal; }
    h2 { margin-bottom:.8em; }
    h2 span { font-size:80%; color:#666; font-weight:normal; }
    h3 { margin:1em 0 .5em 0; }
    h4 { margin:0 0 .5em 0; font-weight: normal; }
    table { 
        border:1px solid #ccc; border-collapse: collapse; background:white; }
    tbody td, tbody th { vertical-align:top; padding:2px 3px; }
    thead th { 
        padding:1px 6px 1px 3px; background:#fefefe; text-align:left; 
        font-weight:normal; font-size:11px; border:1px solid #ddd; }
    tbody th { text-align:right; color:#666; padding-right:.5em; }
    table.vars { margin:5px 0 2px 40px; }
    table.vars td, table.req td { font-family:monospace; }
    table td.code { width:100%;}
    table td.code div { overflow:hidden; }
    table.source th { color:#666; }
    table.source td { 
        font-family:monospace; white-space:pre; border-bottom:1px solid #eee; }
    ul.traceback { list-style-type:none; }
    ul.traceback li.frame { margin-bottom:1em; }
    div.context { margin: 10px 0; }
    div.context ol { 
        padding-left:30px; margin:0 10px; list-style-position: inside; }
    div.context ol li { 
        font-family:monospace; white-space:pre; color:#666; cursor:pointer; }
    div.context ol.context-line li { color:black; background-color:#ccc; }
    div.context ol.context-line li span { float: right; }
    div.commands { margin-left: 40px; }
    div.commands a { color:black; text-decoration:none; }
    #summary { background: #ffc; }
    #summary h2 { font-weight: normal; color: #666; }
    #explanation { background:#eee; }
    #template, #template-not-exist { background:#f6f6f6; }
    #template-not-exist ul { margin: 0 0 0 20px; }
    #traceback { background:#eee; }
    #requestinfo { background:#f6f6f6; padding-left:120px; }
    #summary table { border:none; background:transparent; }
    #requestinfo h2, #requestinfo h3 { position:relative; margin-left:-100px; }
    #requestinfo h3 { margin-bottom:-1em; }
    .error { background: #ffc; }
    .specific { color:#cc3300; font-weight:bold; }
  </style>
  <script type="text/javascript">
  //<!--
    function getElementsByClassName(oElm, strTagName, strClassName){
        // Written by Jonathan Snook, http://www.snook.ca/jon; 
        // Add-ons by Robert Nyman, http://www.robertnyman.com
        var arrElements = (strTagName == "*" && document.all)? document.all :
        oElm.getElementsByTagName(strTagName);
        var arrReturnElements = new Array();
        strClassName = strClassName.replace(/\-/g, "\-");
        var oRegExp = new RegExp("(^|\s)" + strClassName + "(\s|$)");
        var oElement;
        for(var i=0; i<arrElements.length; i++){
            oElement = arrElements[i];
            if(oRegExp.test(oElement.className)){
                arrReturnElements.push(oElement);
            }
        }
        return (arrReturnElements)
    }
    function hideAll(elems) {
      for (var e = 0; e < elems.length; e++) {
        elems[e].style.display = 'none';
      }
    }
    window.onload = function() {
      hideAll(getElementsByClassName(document, 'table', 'vars'));
      hideAll(getElementsByClassName(document, 'ol', 'pre-context'));
      hideAll(getElementsByClassName(document, 'ol', 'post-context'));
    }
    function toggle() {
      for (var i = 0; i < arguments.length; i++) {
        var e = document.getElementById(arguments[i]);
        if (e) {
          e.style.display = e.style.display == 'none' ? 'block' : 'none';
        }
      }
      return false;
    }
    function varToggle(link, id) {
      toggle('v' + id);
      var s = link.getElementsByTagName('span')[0];
      var uarr = String.fromCharCode(0x25b6);
      var darr = String.fromCharCode(0x25bc);
      s.innerHTML = s.innerHTML == uarr ? darr : uarr;
      return false;
    }
    //-->
  </script>
<style id="clearly_highlighting_css" type="text/css">/* selection */ html.clearly_highlighting_enabled ::-moz-selection { background: rgba(246, 238, 150, 0.99); } html.clearly_highlighting_enabled ::selection { background: rgba(246, 238, 150, 0.99); } /* cursor */ html.clearly_highlighting_enabled {    /* cursor and hot-spot position -- requires a default cursor, after the URL one */    cursor: url("chrome-extension://pioclpoplcdbaefihamjohnefbikjilc/clearly/images/highlight--cursor.png") 14 16, text; } /* highlight tag */ em.clearly_highlight_element {    font-style: inherit !important; font-weight: inherit !important;    background-image: url("chrome-extension://pioclpoplcdbaefihamjohnefbikjilc/clearly/images/highlight--yellow.png");    background-repeat: repeat-x; background-position: top left; background-size: 100% 100%; } /* the delete-buttons are positioned relative to this */ em.clearly_highlight_element.clearly_highlight_first { position: relative; } /* delete buttons */ em.clearly_highlight_element a.clearly_highlight_delete_element {    display: none; cursor: pointer;    padding: 0; margin: 0; line-height: 0;    position: absolute; width: 34px; height: 34px; left: -17px; top: -17px;    background-image: url("chrome-extension://pioclpoplcdbaefihamjohnefbikjilc/clearly/images/highlight--delete-sprite.png"); background-repeat: no-repeat; background-position: 0px 0px; } em.clearly_highlight_element a.clearly_highlight_delete_element:hover { background-position: -34px 0px; } /* retina */ @media (min--moz-device-pixel-ratio: 2), (-webkit-min-device-pixel-ratio: 2), (min-device-pixel-ratio: 2) {    em.clearly_highlight_element { background-image: url("chrome-extension://pioclpoplcdbaefihamjohnefbikjilc/clearly/images/highlight--yellow@2x.png"); }    em.clearly_highlight_element a.clearly_highlight_delete_element { background-image: url("chrome-extension://pioclpoplcdbaefihamjohnefbikjilc/clearly/images/highlight--delete-sprite@2x.png"); background-size: 68px 34px; } } </style><style type="text/css"></style><style>[touch-action="none"]{ -ms-touch-action: none; touch-action: none; }[touch-action="pan-x"]{ -ms-touch-action: pan-x; touch-action: pan-x; }[touch-action="pan-y"]{ -ms-touch-action: pan-y; touch-action: pan-y; }[touch-action="scroll"],[touch-action="pan-x pan-y"],[touch-action="pan-y pan-x"]{ -ms-touch-action: pan-x pan-y; touch-action: pan-x pan-y; }</style></head>
<body>

<div id="summary">
  <h1>&lt;type 'exceptions.KeyError'&gt; at /</h1>
  <h2>u'displaythreads/viewthread'</h2>
  <table><tbody><tr>
    <th>Python</th>
    <td>/Users/James/Dropbox/ForumGame/web/application.py in _delegate, line 460</td>
  </tr><tr>
    <th>Web</th>
    <td>GET http://0.0.0.0:8080/</td>
  </tr></tbody></table>
</div>
<div id="traceback">
<h2>Traceback <span>(innermost first)</span></h2>
<ul class="traceback">
<li class="frame">
<code>/Users/James/Dropbox/ForumGame/web/application.py</code> in <code>_delegate</code>
<div class="context" id="c41419680">
<ol start="453" class="pre-context" id="pre41419680" style="display: none;">
<li onclick="toggle(&#39;pre41419680&#39;, &#39;post41419680&#39;)">                        url += '?' + x</li>
<li onclick="toggle(&#39;pre41419680&#39;, &#39;post41419680&#39;)">                raise web.redirect(url)</li>
<li onclick="toggle(&#39;pre41419680&#39;, &#39;post41419680&#39;)">            elif '.' in f:</li>
<li onclick="toggle(&#39;pre41419680&#39;, &#39;post41419680&#39;)">                mod, cls = f.rsplit('.', 1)</li>
<li onclick="toggle(&#39;pre41419680&#39;, &#39;post41419680&#39;)">                mod = __import__(mod, None, None, [''])</li>
<li onclick="toggle(&#39;pre41419680&#39;, &#39;post41419680&#39;)">                cls = getattr(mod, cls)</li>
<li onclick="toggle(&#39;pre41419680&#39;, &#39;post41419680&#39;)">            else:</li>
</ol>
<ol start="460" class="context-line"><li onclick="toggle(&#39;pre41419680&#39;, &#39;post41419680&#39;)">                cls = fvars[f] <span>...</span></li></ol>
<ol start="461" class="post-context" id="post41419680" style="display: none;">
<li onclick="toggle(&#39;pre41419680&#39;, &#39;post41419680&#39;)">            return handle_class(cls)</li>
<li onclick="toggle(&#39;pre41419680&#39;, &#39;post41419680&#39;)">        elif hasattr(f, '__call__'):</li>
<li onclick="toggle(&#39;pre41419680&#39;, &#39;post41419680&#39;)">            return f()</li>
<li onclick="toggle(&#39;pre41419680&#39;, &#39;post41419680&#39;)">        else:</li>
<li onclick="toggle(&#39;pre41419680&#39;, &#39;post41419680&#39;)">            return web.notfound()</li>
<li onclick="toggle(&#39;pre41419680&#39;, &#39;post41419680&#39;)"></li>
</ol>
  </div>

<div class="commands">
<a href="http://0.0.0.0:8080/#" onclick="return varToggle(this, &#39;41419680&#39;)"><span></span> Local vars</a>

</div>

<table class="vars" id="v41419680" style="display: none;"><thead><tr><th>Variable</th><th>Value</th></tr></thead>
<tbody>
<tr><td>args</td><td class="code"><div>[]</div></td></tr>
<tr><td>f</td><td class="code"><div>u'displaythreads/viewthread'</div></td></tr>
<tr><td>fvars</td><td class="code"><div>{'__builtins__': {'ArithmeticError': &lt;type 'exceptions.ArithmeticError'&gt;,
                  'AssertionError': &lt;type 'exceptions.AssertionError'&gt;,
                  'AttributeError': &lt;type 'exceptions.AttributeError'&gt;,
                  'BaseException': &lt;type 'exceptions.BaseException'&gt;,
                  'BufferError': &lt;type 'exceptions.BufferError'&gt;,
                  'BytesWarning': &lt;type 'exceptions.BytesWarning'&gt;,
                  'DeprecationWarning': &lt;type 'exceptions.DeprecationWarning'&gt;,
                  'EOFError': &lt;type 'exceptions.EOFError'&gt;,
                  'Ellipsis': Ellipsis,
                  'EnvironmentError': &lt;type
This question has already been answered. Start a new discussion instead.