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

fix: url param decoding

parent 4df57f00
No related branches found
No related tags found
1 merge request!12Clhp map
# PROG2900
## Dependencies
### Python
## Endpoints
```
\
\update_map
\get_relation
\add_new_lake?lake=name
```
### Server
To run the server...
### Dart & Flutter
### Application
### Database
......@@ -14,8 +23,8 @@ binary in a folder and note its path. Add the path to your system environment va
manage the SQLite database.
## Adding new lakes
The current server only contains the data for a single lake, Mjøsa. To add more lakes
go to https://overpass-turbo.eu/. Once you have navigated to Overpass API, enter
To add a new lake to the system, go to https://overpass-turbo.eu/.
Once you have navigated to Overpass API, enter
the Overpass query below in the left field, but swap 'lakeName' out
with the name of the lake you want to add. Once the query has been adjusted,
press the 'Run' button.
......@@ -44,11 +53,10 @@ IceMap/server/lake_relations. Once you have added the file, run map division...
The result will be two new files named lakeName_centers.txt and lakeName_div.json. The original
lakeName.geojson file should also remain in the system. Additionally, the file named all_lake_names.json
should be updated to contain the newly added lake name.
![img.png](images/resulting-files.png)
![img.png](images/resulting-files.png)
## Endpoints
## Bugs
## Known bugs
## Developers
......@@ -15,10 +15,10 @@ Future<Uint8List> fetchRelation() async {
(X509Certificate cert, String host, int port) => true;
// Execute request to to get_relation endpoint
var parameterValue = 'Mjosa'; // NB temp hardcoded, should use selectedLake directly in url param
var parameterValue = 'Mjøsa'; // NB temp hardcoded, should use selectedLake directly in url param
//var request = await client.getUrl(Uri.parse('${serverURI}get_relation'));
var request = await client.getUrl(Uri.parse('${serverURI}get_relation?lake='
'${Uri.encodeComponent(parameterValue)}'));
'${Uri.encodeFull(parameterValue)}'));
var response = await request.close(); // Close response body at end of function
......
......@@ -2,7 +2,7 @@ import ssl
import json
import sqlite3
from flask import Flask
from urllib.parse import urlparse, parse_qs
from urllib.parse import urlparse, parse_qs, unquote
from consts import SSL_CERT_PATH, SSL_KEY_PATH, HOST, PORT
from http.server import HTTPServer, BaseHTTPRequestHandler
......@@ -62,7 +62,11 @@ class IceHTTP(BaseHTTPRequestHandler):
elif self.path.startswith('/get_relation'):
parsed_path = urlparse(self.path)
query_params = parse_qs(parsed_path.query)
get_divided_map(self, 'Mjosa') # NB temp hardcoded value
lake_name_param = query_params.get('lake', [''])[0]
lake_name = unquote(lake_name_param) # Decode url param
get_divided_map(self, lake_name)
elif self.path.startswith('/add_new_lake'):
parsed_path = urlparse(self.path)
query_params = parse_qs(parsed_path.query)
......
No preview for this file type
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