New webframework on raw WSGI. Successor of poobrains.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

116 lines
2.5 KiB

import ooze
app = ooze.Application()
def front(request):
return "<html>Fröntpage</html>"
def foo(request):
return "Foo"
def foo_bar(request):
return "FooBar"
def bing_bong_fnord(request):
return "BingBongFnord"
def echo_int(request, x):
return x
class RenderThing(ooze.rendering.Renderable):
def __init__(self):
self.thing = "I'm a string coming from a renderable object!"
class RenderParam(ooze.rendering.Renderable):
def __init__(self, param):
self.param = param
def thing(request, name):
return name
def thing_option(request, name, option):
return f"{name}: {option}"
def cookie_set(request, value):
response = app.response_class(request)
response.cookies['cookie-foo'] = value
return response
def cookie_get(request):
return request.cookies['cookie-foo']
#@app.route('asdf/<path:bonk>/more') # fails because path is multipart, TODO: make this a test
#def asdf(request, bonk):
# return bonk
#from ooze import dominion
#renderer = dominion.Renderer(['ooze/themes/default/templates'])
#def dominiontest(request, content):
# return renderer.template_render('main', content=content)
fnord = ooze.Subsite()
app.register_subsite('fnord', fnord)
def fnord_front(request):
return "FNORD"
class Bong(ooze.rendering.Renderable):
def __init__(self, time):
self.time = time
if time == '4:20':
self.message = 'BLAZE IT!!'
elif time == '13:12':
self.message = "ACAB O'Glock!"
self.message = 'ZZZZZZZZ…'
whoop = ooze.Subsite()
def whoo_bonk(request):
return request.path # /fnord/whoop/bonk/
fnord.register_subsite('whoop', whoop)
multipath = ooze.Subsite()
app.register_subsite('multi/path', multipath)
def medumb(request):
return request.path # /multi/path/running-out-of-stupid-ideas
def sessionget(request, key):
return request.session[key]
def sessionset(request, key, value):
request.session[key] = value
return f"Set '{key}' to '{value}'."