Start implementing CalDAV
This commit is contained in:
parent
8df8de76fc
commit
b6ec2f7126
|
@ -8,6 +8,7 @@ from subprocess import run
|
||||||
|
|
||||||
import cherrypy
|
import cherrypy
|
||||||
|
|
||||||
|
from defusedxml.ElementTree import fromstring
|
||||||
from icalendar import Calendar, Todo
|
from icalendar import Calendar, Todo
|
||||||
|
|
||||||
GITEA_REPO_URL="https://git.bitmessage.org/api/v1"
|
GITEA_REPO_URL="https://git.bitmessage.org/api/v1"
|
||||||
|
@ -57,7 +58,7 @@ def get_token(input_token):
|
||||||
|
|
||||||
class Root:
|
class Root:
|
||||||
@cherrypy.expose
|
@cherrypy.expose
|
||||||
def todo(self):
|
def index(self):
|
||||||
cherrypy.response.headers['WWW-Authenticate'] = \
|
cherrypy.response.headers['WWW-Authenticate'] = \
|
||||||
'Basic realm="ICS access"'
|
'Basic realm="ICS access"'
|
||||||
authorization = cherrypy.request.headers.get('Authorization', ':')
|
authorization = cherrypy.request.headers.get('Authorization', ':')
|
||||||
|
@ -71,8 +72,34 @@ class Root:
|
||||||
raise cherrypy.HTTPError(401, 'Unauthorized')
|
raise cherrypy.HTTPError(401, 'Unauthorized')
|
||||||
return(process_combined(combined))
|
return(process_combined(combined))
|
||||||
|
|
||||||
|
class Dav:
|
||||||
|
exposed = True
|
||||||
|
#@cherrypy.expose
|
||||||
|
@cherrypy.tools.accept(media='application/xml')
|
||||||
|
def PROPFIND(self):
|
||||||
|
cl = cherrypy.request.headers['Content-Length']
|
||||||
|
rawbody = cherrypy.request.body.read(size=int(cl))
|
||||||
|
et = fromstring(rawbody)
|
||||||
|
for child in et:
|
||||||
|
if child.tag == '{DAV:}prop':
|
||||||
|
for x in child:
|
||||||
|
print("T:", x.tag, "; A:", x.attrib)
|
||||||
|
#print(et)
|
||||||
|
print(f"BODY {rawbody}")
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
conf = {
|
||||||
|
'/dav': {
|
||||||
|
'request.dispatch': cherrypy.dispatch.MethodDispatcher(),
|
||||||
|
'request.methods_with_bodies': ('POST',
|
||||||
|
'PUT',
|
||||||
|
'PROPFIND'),
|
||||||
|
}
|
||||||
|
}
|
||||||
cherrypy.config.update({'server.socket_host': '0.0.0.0',
|
cherrypy.config.update({'server.socket_host': '0.0.0.0',
|
||||||
'server.socket_port': 8080,
|
'server.socket_port': 8080,
|
||||||
})
|
})
|
||||||
cherrypy.quickstart(Root(), '/')
|
webapp = Root()
|
||||||
|
webapp.dav = Dav()
|
||||||
|
cherrypy.quickstart(webapp, '/', conf)
|
|
@ -1,2 +1,3 @@
|
||||||
cherrypy
|
cherrypy
|
||||||
|
defusedxml
|
||||||
icalendar
|
icalendar
|
||||||
|
|
Loading…
Reference in New Issue
Block a user