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

:add: update_map endpoint, not tested2

parent 61e1bcbd
No related branches found
No related tags found
No related merge requests found
File added
File added
......@@ -2,7 +2,7 @@ import json
from flask import Flask, jsonify
import sys
sys.path.append('..') # Add root directory to the system path
from server import DataPoint
from data_structs import DataPoint
def process_data_point(data_point):
try:
......
......@@ -20,6 +20,4 @@ class DataPoint:
self.safety_level = safety_level
self.accuracy = accuracy
# Test instance
test_instance = DataPoint(longitude=1.5, latitude=2.5, precipitation=10.0, thickness = 10.0, safety_level= 5, max_weight= 80)
......@@ -3,6 +3,8 @@ from http.server import HTTPServer, BaseHTTPRequestHandler
from pymongo import MongoClient
from pymongo.server_api import ServerApi
from consts import DB_NAME, COLLECTION, MONGO_URI, MONGO_CERT_PATH, SSL_CERT_PATH, SSL_KEY_PATH, HOST, PORT
from calc_model.update_map import process_data_point
from data_structs import DataPoint
import atexit
import ssl
......@@ -29,6 +31,21 @@ class IceHTTP(BaseHTTPRequestHandler):
self.send_header("Content-type", "text/plain")
self.end_headers()
self.wfile.write(b"Root path hit!")
elif self.path == '/update_map':
# NB temporary test data
data_point_instance = DataPoint(longitude=1.0, latitude=2.0, precipitation=10.5, thickness=3.0, max_weight=50.0, safety_level=3, accuracy=8)
# Get response from process_data_point
response, status_code = process_data_point(data_point_instance)
# Send the response
self.send_response(status_code)
self.send_header("Content-type", "application/json")
self.end_headers()
# Write response to response object
self.wfile.write(response.encode('utf-8'))
# Start a server on port 8443 using defined HTTP class
if __name__ == "__main__":
......
import sys
sys.path.append('..') # Add root directory to the system path
from server import DataPoint
from data_structs 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)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment