#!/usr/local/bin/python

# Remember to adjust your hash-bang line above to correspond to the
# PATH of python on your machine. Type `which python` at the command
# prompt to find out.

import json
from sqlitedict import SqliteDict
import cgi

form = cgi.FieldStorage()

print("Content-Type: text/html")
print("")

d = SqliteDict('./my_db.sqlite', autocommit=True)

id = form["id"].value
x = form["x"].value
y = form["y"].value

d[id] = { "x":x, "y":y }

return_data = {}
for key, value in d.items():
    return_data[key] = value
print(json.dumps(return_data))