ocarina/libsaria/server/pages/__init__.py
Bryan Schumaker c02bffb652 libsaria: Web server controls playback
I can choose songs to play by clicking rows in an html table.  I also
write text to the client as it becomes available, rather than doing it
all at once.
2011-05-15 15:39:14 -04:00

39 lines
628 B
Python

# Bryan Schumaker (5 / 15 / 2011)
import root
import rpc
docs = {}
docs.update(root.docs)
docs.update(rpc.docs)
types = {
"html":"text/html",
"js":"text/javascript",
}
def lookup(file):
doc = docs
for i, cmp in enumerate(file):
doc = doc.get(cmp, None)
if doc == None:
break
elif len(doc) == 2:
break
return doc, i + 1
def has_file(file):
doc, index = lookup(file)
return doc != None
def file_type(file):
(func, type), index = lookup(file)
return type
def page_text(write, file):
(func, type), index = lookup(file)
if len(file) > index:
res = func(write, file[index:])
else:
res = func(write)