Skip to content

Instantly share code, notes, and snippets.

@tonetheman
Created March 4, 2014 17:32
Show Gist options
  • Select an option

  • Save tonetheman/9351450 to your computer and use it in GitHub Desktop.

Select an option

Save tonetheman/9351450 to your computer and use it in GitHub Desktop.
simple template with web.py
import web
urls = (
"^/scale$", "Scale",
)
PAGE = """
<html>
<body>
id : $id<br />
scale : $scale<br />
</body>
</html>
"""
class Scale:
def handle(self):
inp = web.input()
myid = -1
if inp.has_key("id"):
myid = inp.id
scale = -1
try:
scale = float(inp.scale)
except:
pass
data = { "scale" : scale, "id" : myid }
tmpl = web.template.Template(PAGE, globals = data)
return tmpl()
def GET(self):
inp = web.input()
return self.handle()
def POST(self):
inp = web.input()
return self.handle()
if __name__ == "__main__":
app = web.application(urls,globals())
app.run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment