Skip to content
Snippets Groups Projects
Commit a6212767 authored by Sara Savanovic Djordjevic's avatar Sara Savanovic Djordjevic
Browse files

add: stub, not tested

parent 04f97f0b
No related branches found
No related tags found
No related merge requests found
[
{
"longitude": 1.0,
"latitude": 2.0,
"precipitation": 10.5,
"thickness": 3.0,
"max_weight": 50.0,
"safety_level": 2.5,
"accuracy": 8
},
{
"longitude": -3.5,
"latitude": 4.5,
"precipitation": 5.0,
"thickness": 2.8,
"max_weight": 45.0,
"safety_level": 3.2,
"accuracy": 9
}
]
\ No newline at end of file
import sys
sys.path.append('../..') # Add root directory to the system path
from server import DataPoint
# Test instances
test_data1 = DataPoint(longitude=1.0, latitude=2.0, precipitation=10.5, thickness=3.0, max_weight=50.0, safety_level=2.5, accuracy=8)
test_data2 = DataPoint(longitude=-3.5, latitude=4.5, precipitation=5.0, thickness=2.8, max_weight=45.0, safety_level=3.2, accuracy=9)
test_data3 = DataPoint(longitude=0.0, latitude=0.0, precipitation=None, thickness=0.0, max_weight=0.0, safety_level=3.0, accuracy=9)
import json
from flask import Flask, jsonify
import sys
sys.path.append('..') # Add root directory to the system path
from server import DataPoint
def process_data_point(data_point):
try:
# Convert DataPoint instance to JSON string
json_data = json.dumps(data_point.__dict__)
# Write JSON object to response object
response = jsonify(json_data)
return response, 200
except Exception as e:
print(f"Error in converting point data to JSON: {e}")
return jsonify({"error": "Internal Server Error"}), 500
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment