diff --git a/backend/__pycache__/events.cpython-311.pyc b/backend/__pycache__/events.cpython-311.pyc new file mode 100644 index 0000000..5a6b2c7 Binary files /dev/null and b/backend/__pycache__/events.cpython-311.pyc differ diff --git a/backend/__pycache__/main.cpython-311.pyc b/backend/__pycache__/main.cpython-311.pyc index 387bfa1..2d1f4db 100644 Binary files a/backend/__pycache__/main.cpython-311.pyc and b/backend/__pycache__/main.cpython-311.pyc differ diff --git a/backend/curl_request.sh b/backend/curl_request.sh new file mode 100755 index 0000000..36ef229 --- /dev/null +++ b/backend/curl_request.sh @@ -0,0 +1,12 @@ +curl -X POST http://127.0.0.1:8000/events -H "Content-Type: application/json" -d '{ + "room_id": 1, + "creator_id": 2, + "event_type": "proposal", + "title": "Filmavond", + "description": "Samen een film kijken en snacks halen", + "start_time": "2026-08-15 20:00", + "end_time": "2026-08-15 23:00", + "visibility": "room", + "status": "proposed", + "min_people": 4 +}' \ No newline at end of file diff --git a/backend/main.py b/backend/main.py index 3d0ab7c..c7b7c3f 100644 --- a/backend/main.py +++ b/backend/main.py @@ -2,9 +2,9 @@ # We had the problem of never agreeing when or where # we should meet up, and I hope this fixes the problem. -from fastapi import FastAPI +from fastapi import FastAPI, Request from database import fetch_all -from events.py import create_event +from events import create_event app = FastAPI( title="Calendar API", @@ -31,5 +31,41 @@ def database_status(): "tables": [table["name"] for table in tables] } -@app.ge("/events") -def create_events(): +@app.post("/events") +async def api_create_event(request: Request): + data = await request.json() + + print(data) + + + event_id = create_event( + room_id=data["room_id"], + creator_id=data["creator_id"], + event_type=data["event_type"], + title=data["title"], + description=data["description"], + start_time=data["start_time"], + end_time=data["end_time"], + visibility=data["visibility"], + status=data["status"], + min_people=data["min_people"] + ) + + return { + "received": data + } +# def give_data(): +# event = create_event( +# room_id=, +# creator_id=, +# event_type=, +# title=, +# description=, +# start_time=, +# end_time=, +# visibility=, +# status=, +# min_people= +# ) + +# print("Nieuw event ID:", event) \ No newline at end of file diff --git a/database/calendar.db b/database/calendar.db index 1f7b0dc..c36ae9d 100644 Binary files a/database/calendar.db and b/database/calendar.db differ diff --git a/database/calendar.db-journal b/database/calendar.db-journal deleted file mode 100644 index a63a7fa..0000000 Binary files a/database/calendar.db-journal and /dev/null differ diff --git a/start_server.sh b/start_server.sh new file mode 100644 index 0000000..a4b79e9 --- /dev/null +++ b/start_server.sh @@ -0,0 +1 @@ +python3 -m uvicorn main:app --reload