route /actes/<house> ok

develop
gwen 2 years ago
parent 7b1c31c9e5
commit 2caf6cf49d

@ -16,14 +16,12 @@ _Nota_ : commands to execute through the terminal (Linux or macOS)
- Go to the following directory : `cd webapp`; - Go to the following directory : `cd webapp`;
- Install the environment : `python3 -m venv .venv`. - Install the environment : `python3 -m venv .venv`.
- Install the packages and libraries : - Install the packages and libraries :
- Activate the environment : `source bootstrap.sh`;
- Installation : `pip install -r requirements.txt` - Installation : `pip install -r requirements.txt`
- Exit the environment : `deactivate`; - Exit the environment : `deactivate`;
## Launch ## Launch
- Activate the environment : `source bootstrap.sh`; - Launch : `python index.py`;
- Launch : `flask run`;
- Go to http://127.0.0.1:5000/; - Go to http://127.0.0.1:5000/;
- Stop : `ctrl + c`; - Stop : `ctrl + c`;
- Exit the environment : `deactivate`. - Exit the environment : `deactivate`.

@ -17,9 +17,11 @@ main = Blueprint("main", __name__, url_prefix="/")
username = urllib.parse.quote_plus(dbadmin) username = urllib.parse.quote_plus(dbadmin)
password = urllib.parse.quote_plus(dbpassword) password = urllib.parse.quote_plus(dbpassword)
dbclient = MongoClient(f'mongodb://{username}:{password}@{server_ip}:27017') dbclient = MongoClient(f'mongodb://{username}:{password}@{server_ip}:27017')
# database
actesdb = dbclient["actesdb"] actesdb = dbclient["actesdb"]
# # collections
housecol = actesdb["house"] housecol = actesdb["house"]
# the acte collection is the most important collection
actecol = actesdb["acte"] actecol = actesdb["acte"]
helpers = actesdb["helpers"] helpers = actesdb["helpers"]
#folium_map = actesdb["folium_map"] #folium_map = actesdb["folium_map"]
@ -48,7 +50,7 @@ def bigram_prince(prince):
def trigram_house(house): def trigram_house(house):
return house_trigram[house] return house_trigram[house]
# TODO: write tests in the datascience project # TODO: write tests in the datascience project `datascience/tests`
#print(bigram_prince("Agnes")) #print(bigram_prince("Agnes"))
#print(bigram_prince("Arthur")) #print(bigram_prince("Arthur"))
#print(bigram_prince("Bernard")) #print(bigram_prince("Bernard"))
@ -87,13 +89,25 @@ def actes(house):
"""actes route """actes route
shows the princes in the selected house shows the princes in the selected house
:param: the house in the url is the house name
with a capital letter at the beginning
example: `house = "Berry"`
""" """
#house = "Berry" #for code in actecol.distinct('prince_code'):
# FIXME faire des princes correspondant à la maison (house) sélectionnée # print(code)
# Corpus > Bourbon # house in the store shall be in lower case, but let's force it, just in case
princes = [("Charles Ier de Bourbon", 36), ("Agnès de Bourgogne", 38), house = house.lower()
("Marie de Berry", 39)] # [(prince_name, prince_code)] means for example:
return render_template("corpus.html", house=house, princes=princes) # [("Charles Ier de Bourbon", "Ch_i"), ("Agnès de Bourgogne", "Agn_i")]
princes = []
for act in actecol.find({"house":house}):
prince_name = act['prince_name'].capitalize()
prince_code = act['prince_code'].capitalize()
if (prince_name, prince_code) not in princes:
princes.append((prince_name, prince_code))
return render_template("corpus.html", house=house.capitalize(), princes=princes)
@main.route("/actes/<house>/<prince>") # don't put a slash at the end @main.route("/actes/<house>/<prince>") # don't put a slash at the end
@ -135,7 +149,7 @@ def geoloc():
folium.Marker( folium.Marker(
location=[place['latitude'], place['longitude']], location=[place['latitude'], place['longitude']],
popup=place['name'], popup=place['name'],
#icon=folium.Icon(icon="cloud") icon=folium.Icon(color='lightgray', icon="circle", prefix='fa')
#icon=folium.Icon(color='lightgray', icon='home', prefix='fa') #icon=folium.Icon(color='lightgray', icon='home', prefix='fa')
).add_to(m) ).add_to(m)
geolocalisation = m._repr_html_() geolocalisation = m._repr_html_()

Loading…
Cancel
Save