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

update: readme

parent d8137388
No related branches found
No related tags found
1 merge request!2App2
# PROG2900
## Database setup
This project requires the use of MongoDB. To use the application, a MongoDB Atlas database must first be set up and configured. The following is a step by step guide of how to set up the database:
1. Create a user/Log into MongoDB Atlas (https://www.mongodb.com/atlas)
2. ?Create an organization?
3. On the left-hand side in the menu under "Organization", press the "Project" tab.
## Dependencies
### Python
To run the server...
![Alt text](images/image-1.png)
### Dart & Flutter
4. In the right-hand corner, press "New Project" and name it as you wish.
![Alt text](images/image-2.png)
### Database
This project requires SQLite3. Download the precompiled binary for your operating system.
Precompiled binaries can be found on https://www.sqlite.org/download.html. Extract the downloaded
binary in a folder and note its path. Add the path to your system environment variables. Now you can
manage the SQLite database.
5. After successful creation, you should be taken to a page called "Overview". In the middle of the page right below "Create a deployment", press the button that says "+ Create"
## Endpoints
![Alt text](images/image.png)
## Bugs
6. When creating a database deployment, select the M10 template. The provider and region can be selected as is most fit to the organization.
![Alt text](images/image-4.png)
7. Name your cluster appropriately. Optionally, give your cluster tags. Press "Create".
![Alt text](images/image-5.png)
8. After deploying the database you will be taken to the Security Quickstart page. Choose the option "certificate", and chose an appropriate "Common Name". Toggle the "Download certificate when user is added" on, and select a certificate expiration. Then press the "Add User" button.
![Alt text](images/image-7.png)
9. After pressing "Add User", the access certificate will automatically be downloaded to your PC. The certificate will be used to access your database, and should be kept in a safe location to prevent unauthorized access.
![Alt text](images/image-8.png)
10. Still in the Security Quickstart page, scroll down to the "Where would you like to connect from?" section. Press "Add My Current IP Address", and then press "Finish and close" at the bottom of the page.
![Alt text](images/image-9.png)
![Alt text](images/image-10.png)
11. You have now created a database deployment, but you will still have to configure the connection to the database.
### Database connection
1. To create a connection with the database, locate your newly created database deployment and press "Connect"
![alt text](images/image-11.png)
2. Select "Drivers"
![alt text](images/image-12.png)
\ No newline at end of file
## Developers
images/image-1.png

10.6 KiB

images/image-10.png

1.2 KiB

images/image-11.png

48.2 KiB

images/image-12.png

34.9 KiB

images/image-2.png

1.71 KiB

images/image-3.png

54.1 KiB

images/image-4.png

59.6 KiB

images/image-5.png

48.8 KiB

images/image-6.png

52.3 KiB

images/image-7.png

42.7 KiB

images/image-8.png

10 KiB

images/image-9.png

41.2 KiB

images/image.png

41.1 KiB

......@@ -10,7 +10,6 @@ import sqlite3
app = Flask(__name__)
terminate_server = 0
class IceHTTPServer(HTTPServer):
def __init__(self, server_address, handler_class, cursor):
super().__init__(server_address, handler_class)
......
No preview for this file type
......@@ -33,22 +33,22 @@ def get_all_markers(self, cursor, valid: bool, waterBodyName):
for row in rows:
measurement_id = row[0]
# Create subdivision object for current row
# Create subdivision new object
sub_division = {
'SubDivisionID': row[6],
'SubdivID': row[6],
'GroupID': row[7],
'MinimumThickness': row[8],
'AverageThickness': row[9],
'CenterLatitude': row[10],
'CenterLongitude': row[11],
'MinThickness': row[8],
'AvgThickness': row[9],
'CenLatitude': row[10],
'CenLongitude': row[11],
'Accuracy': row[12]
}
# Check if measurement ID already exists in measurement_data
if measurement_id in measurement_data:
# Check if the data object already exists in the list
if sub_division not in measurement_data[measurement_id]['SubDivision']:
measurement_data[measurement_id]['SubDivision'].append(sub_division)
if sub_division not in measurement_data[measurement_id]['Subdivisions']:
measurement_data[measurement_id]['Subdivisions'].append(sub_division)
else:
# Create a new entry for measurement_id if it does not already exist in the list
......@@ -60,14 +60,14 @@ def get_all_markers(self, cursor, valid: bool, waterBodyName):
'SensorType': row[3],
'Active': bool(row[4])
},
'SubDivision': [sub_division], # Array of sub_division objects
'Subdivisions': [sub_division], # Array of sub_division objects
}
# Convert dictionary values to list of measurements
data = list(measurement_data.values())
if len(rows) == 0 or len(data) == 0: # Return 500 and empty list if no data is found
print(f"An error occurred while querying the database")
print(f"Error in querying database")
resp_code = 500
marker_data = '[]'
else:
......
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