diff --git a/src/__main__.py b/src/__main__.py index 232b2da..3fc0d03 100644 --- a/src/__main__.py +++ b/src/__main__.py @@ -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), + ) diff --git a/src/server/__init__.py b/src/server/__init__.py new file mode 100644 index 0000000..8cb1c6d --- /dev/null +++ b/src/server/__init__.py @@ -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'