
import flask

from pony.orm import db_session

from planer.daemon.db import db
from planer.daemon.json_converter import as_json

app = flask.Flask("Planer Http API")


@app.route('/calendars', methods=["GET"])
@db_session
def calendars():
    return as_json(db.Calendar.select())


@app.route('/calendars/<int:calendar>', methods=["GET"])
@db_session
def get_calendar(calendar):
    return as_json(db.Calendar[calendar])


@app.route('/events/<int:event>', methods=["GET"])
@db_session
def get_event(event):
    return as_json(db.Event[event])


@app.route('/events/new', methods=["POST"])
def new_event():
    pass



@@ -1,18 +1,94 @@
 %0A
+from flask 
 import 
-f
+F
 lask%0A
+from werkzeug.exceptions import HTTPException, default_exceptions
 %0Afro
@@ -203,20 +203,33 @@
 on%0A%0A
+__all__ = %5B%22app%22%5D%0A%0A
 app = 
-flask.
 Flas
@@ -701,8 +701,326 @@
  pass%0A%0A%0A
+# Handling error's (source: http://flask.pocoo.org/snippets/83/)%0Adef make_json_error(ex):%0A    response = as_json(%0A            %7B %22message%22: str(ex) %7D,%0A            status=ex.code if isinstance(ex, HTTPException) else 500)%0A    return response%0A%0Afor code in default_exceptions:%0A    app.errorhandler(code)(make_json_error)%0A%0A

add generic error handling