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
|
from datetime import date
|
||||||
import caldav
|
import caldav
|
||||||
|
|
||||||
|
from .server import app
|
||||||
|
|
||||||
|
|
||||||
parser = argparse.ArgumentParser(description='Web-based CalDav client')
|
parser = argparse.ArgumentParser(description='Web-based CalDav client')
|
||||||
parser.add_argument('-c', '--config', type=Path, default='config.ini',
|
parser.add_argument('-c', '--config', type=Path, default='config.ini',
|
||||||
|
@ -25,17 +27,10 @@ log = logging.getLogger('saturn')
|
||||||
|
|
||||||
log.info('Starting 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():
|
if __name__ == '__main__':
|
||||||
for event in cal.date_search(start=date.today()):
|
app.run(
|
||||||
pp(event)
|
host=config.get('server', 'host', fallback=None),
|
||||||
event.load()
|
port=config.get('server', 'port', fallback=None),
|
||||||
pp(event.instance)
|
debug=config.get('server', 'debug', fallback=None),
|
||||||
pp(event.instance.vevent.dtstart.value)
|
)
|
||||||
sys.exit(0)
|
|
||||||
|
|
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