2022-08-15 20:52:11 +00:00
|
|
|
import ooze
|
|
|
|
|
2022-08-23 00:38:12 +00:00
|
|
|
app = ooze.Application()
|
2022-08-15 20:52:11 +00:00
|
|
|
|
|
|
|
@app.route('')
|
2022-08-23 00:38:12 +00:00
|
|
|
def front(request):
|
2022-08-15 20:52:11 +00:00
|
|
|
return "<html>Fröntpage</html>"
|
|
|
|
|
|
|
|
@app.route('foo')
|
2022-08-23 00:38:12 +00:00
|
|
|
def foo(request):
|
2022-08-15 20:52:11 +00:00
|
|
|
return "Foo"
|
|
|
|
|
|
|
|
@app.route('foo/bar')
|
2022-08-23 00:38:12 +00:00
|
|
|
def foo_bar(request):
|
2022-08-15 20:52:11 +00:00
|
|
|
return "FooBar"
|
|
|
|
|
|
|
|
@app.route('bing/bong/fnord')
|
2022-08-23 00:38:12 +00:00
|
|
|
def bing_bong_fnord(request):
|
2022-08-15 20:52:11 +00:00
|
|
|
return "BingBongFnord"
|
2022-08-17 02:46:05 +00:00
|
|
|
|
|
|
|
@app.route('echoint/<int:x>')
|
2022-08-23 00:38:12 +00:00
|
|
|
def echo_int(request, x):
|
2022-08-18 00:48:50 +00:00
|
|
|
return x
|
2022-08-20 21:53:05 +00:00
|
|
|
|
|
|
|
@app.expose('renderthing')
|
|
|
|
class RenderThing(ooze.rendering.Renderable):
|
|
|
|
|
|
|
|
def __init__(self):
|
|
|
|
self.thing = "I'm a string coming from a renderable object!"
|
|
|
|
|
|
|
|
@app.expose('renderparam/<str:param>')
|
|
|
|
class RenderParam(ooze.rendering.Renderable):
|
|
|
|
|
|
|
|
def __init__(self, param):
|
|
|
|
|
|
|
|
self.param = param
|
2022-08-23 00:38:12 +00:00
|
|
|
|
2022-08-27 22:31:44 +00:00
|
|
|
@app.route('thing/<str:name>')
|
|
|
|
def thing(request, name):
|
|
|
|
return name
|
|
|
|
|
|
|
|
@app.route('thing/<str:name>/<str:option>')
|
|
|
|
def thing_option(request, name, option):
|
|
|
|
return f"{name}: {option}"
|
|
|
|
|
2022-11-07 22:59:06 +00:00
|
|
|
@app.route('cookie/set/<str:value>')
|
|
|
|
def cookie_set(request, value):
|
|
|
|
|
|
|
|
response = app.response_class(request)
|
|
|
|
response.cookies['cookie-foo'] = value
|
|
|
|
|
|
|
|
return response
|
|
|
|
|
|
|
|
@app.route('cookie/get')
|
|
|
|
def cookie_get(request):
|
|
|
|
|
|
|
|
return request.cookies['cookie-foo']
|
|
|
|
|
2022-08-27 22:31:44 +00:00
|
|
|
#@app.route('asdf/<path:bonk>/more') # fails because path is multipart, TODO: make this a test
|
|
|
|
#def asdf(request, bonk):
|
|
|
|
# return bonk
|
|
|
|
|
2022-12-29 03:38:38 +00:00
|
|
|
#from ooze import dominion
|
|
|
|
#renderer = dominion.Renderer(['ooze/themes/default/templates'])
|
2022-12-14 18:44:49 +00:00
|
|
|
|
2022-12-29 03:38:38 +00:00
|
|
|
#@app.route('dominiontest/<content>')
|
|
|
|
#def dominiontest(request, content):
|
|
|
|
#
|
|
|
|
# return renderer.template_render('main', content=content)
|
2022-12-14 18:44:49 +00:00
|
|
|
|
2022-08-23 00:38:12 +00:00
|
|
|
fnord = ooze.Subsite()
|
|
|
|
app.register_subsite('fnord', fnord)
|
|
|
|
|
|
|
|
@fnord.route('')
|
|
|
|
def fnord_front(request):
|
|
|
|
return "FNORD"
|
|
|
|
|
|
|
|
@fnord.expose('bong/<time>')
|
|
|
|
class Bong(ooze.rendering.Renderable):
|
|
|
|
|
|
|
|
def __init__(self, time):
|
|
|
|
|
|
|
|
self.time = time
|
|
|
|
if time == '4:20':
|
|
|
|
self.message = 'BLAZE IT!!'
|
|
|
|
elif time == '13:12':
|
2022-11-07 22:59:06 +00:00
|
|
|
self.message = "ACAB O'Glock!"
|
2022-08-23 00:38:12 +00:00
|
|
|
else:
|
|
|
|
self.message = 'ZZZZZZZZ…'
|
|
|
|
|
|
|
|
whoop = ooze.Subsite()
|
|
|
|
|
|
|
|
@whoop.route('bonk')
|
|
|
|
def whoo_bonk(request):
|
|
|
|
return request.path # /fnord/whoop/bonk/
|
|
|
|
|
|
|
|
fnord.register_subsite('whoop', whoop)
|
|
|
|
|
|
|
|
multipath = ooze.Subsite()
|
|
|
|
app.register_subsite('multi/path', multipath)
|
|
|
|
|
|
|
|
@multipath.route('running-out-of-stupid-ideas')
|
|
|
|
def medumb(request):
|
|
|
|
return request.path # /multi/path/running-out-of-stupid-ideas
|
2023-02-12 00:08:53 +00:00
|
|
|
|
2023-03-05 22:38:14 +00:00
|
|
|
@app.route('session/<key>')
|
|
|
|
def sessionget(request, key):
|
|
|
|
|
|
|
|
return request.session[key]
|
|
|
|
|
2023-02-12 00:08:53 +00:00
|
|
|
@app.route('session/<key>/<value>')
|
|
|
|
def sessionset(request, key, value):
|
|
|
|
|
|
|
|
request.session[key] = value
|
|
|
|
|
|
|
|
return f"Set '{key}' to '{value}'."
|
2024-02-05 20:52:59 +00:00
|
|
|
|
|
|
|
@app.expose('exampleform') # <- auto-sets action
|
|
|
|
class ExampleForm(ooze.forms.Form):
|
|
|
|
|
|
|
|
warning = ooze.dominion.elements.P("This will florp your shpergle! Proceed?")
|
|
|
|
name = ooze.forms.fields.Text(label='Name of the shpergle to florp')
|
|
|
|
florp = ooze.forms.fields.Button('Florp')
|
|
|
|
|
|
|
|
@app.expose('dynamicform')
|
|
|
|
class DynamicForm(ooze.forms.Form):
|
|
|
|
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
|
|
|
|
|
|
super().__init__(*args, **kwargs)
|
|
|
|
self.fields['bongo'] = ooze.forms.fields.Text(label="Bongo")
|