Added Flask server
This commit is contained in:
parent
a907ce357d
commit
a1349a6a4d
2 changed files with 27 additions and 13 deletions
|
@ -10,6 +10,8 @@ from pathlib import Path
|
|||
from datetime import date
|
||||
import caldav
|
||||
|
||||
from .server import app
|
||||
|
||||
|
||||
parser = argparse.ArgumentParser(description='Web-based CalDav client')
|
||||
parser.add_argument('-c', '--config', type=Path, default='config.ini',
|
||||
|
@ -25,17 +27,10 @@ log = logging.getLogger('saturn')
|
|||
|
||||
log.info('Starting saturn')
|
||||
|
||||
cli = caldav.davclient.DAVClient(
|
||||
config.get('caldav', 'host'),
|
||||
username=config.get('caldav', 'username', fallback=None),
|
||||
password=config.get('caldav', 'password', fallback=None),
|
||||
)
|
||||
pri = cli.principal()
|
||||
|
||||
for cal in pri.calendars():
|
||||
for event in cal.date_search(start=date.today()):
|
||||
pp(event)
|
||||
event.load()
|
||||
pp(event.instance)
|
||||
pp(event.instance.vevent.dtstart.value)
|
||||
sys.exit(0)
|
||||
if __name__ == '__main__':
|
||||
app.run(
|
||||
host=config.get('server', 'host', fallback=None),
|
||||
port=config.get('server', 'port', fallback=None),
|
||||
debug=config.get('server', 'debug', fallback=None),
|
||||
)
|
||||
|
|
19
src/server/__init__.py
Normal file
19
src/server/__init__.py
Normal file
|
@ -0,0 +1,19 @@
|
|||
import flask
|
||||
|
||||
app = flask.Flask(__name__)
|
||||
|
||||
@app.route('/')
|
||||
def home():
|
||||
return 'Hello World!'
|
||||
#cli = caldav.davclient.DAVClient(
|
||||
# config.get('caldav', 'host'),
|
||||
# username=config.get('caldav', 'username', fallback=None),
|
||||
# password=config.get('caldav', 'password', fallback=None),
|
||||
#)
|
||||
#pri = cli.principal()
|
||||
#
|
||||
#res = ''
|
||||
#for cal in pri.calendars():
|
||||
# for event in cal.date_search(start=date.today()):
|
||||
# res += f'<li>{event.instance.vevent.dtstart.value}</li>'
|
||||
#return f'<ul>{res}</ul>'
|
Reference in a new issue