|
|
|
|
@ -4,6 +4,41 @@ from flask import Blueprint, abort, render_template, request, send_from_director
|
|
|
|
|
|
|
|
|
|
main = Blueprint("main", __name__, url_prefix="/")
|
|
|
|
|
|
|
|
|
|
from pymongo import MongoClient
|
|
|
|
|
|
|
|
|
|
import urllib.parse
|
|
|
|
|
|
|
|
|
|
username = urllib.parse.quote_plus('dbadmin')
|
|
|
|
|
password = urllib.parse.quote_plus('BrOp48la%Mrops')
|
|
|
|
|
myclient = MongoClient('mongodb://%s:%s@149.202.41.75:27017' % (username, password))
|
|
|
|
|
mydb = myclient["actesdb"]
|
|
|
|
|
dbhouse = mydb["house"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# (unproudly borrowed from the flask-pymongo's helpers :)
|
|
|
|
|
from flask import abort
|
|
|
|
|
def find_one_or_404(self, *args, **kwargs):
|
|
|
|
|
"""Find a single document or raise a 404.
|
|
|
|
|
|
|
|
|
|
This is like :meth:`~pymongo.collection.Collection.find_one`, but
|
|
|
|
|
rather than returning ``None``, cause a 404 Not Found HTTP status
|
|
|
|
|
on the request.
|
|
|
|
|
|
|
|
|
|
.. code-block:: python
|
|
|
|
|
|
|
|
|
|
@app.route("/user/<username>")
|
|
|
|
|
def user_profile(username):
|
|
|
|
|
user = mongo.db.users.find_one_or_404({"_id": username})
|
|
|
|
|
return render_template("user.html",
|
|
|
|
|
user=user)
|
|
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
found = self.find_one(*args, **kwargs)
|
|
|
|
|
if found is None:
|
|
|
|
|
abort(404)
|
|
|
|
|
return found
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@main.route("/")
|
|
|
|
|
def home():
|
|
|
|
|
"""home route"""
|
|
|
|
|
@ -12,17 +47,19 @@ def home():
|
|
|
|
|
|
|
|
|
|
@main.route("/about/")
|
|
|
|
|
def about():
|
|
|
|
|
"""home route"""
|
|
|
|
|
"""about route"""
|
|
|
|
|
return render_template("about.html")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@main.route("/actes/")
|
|
|
|
|
def corpora_all():
|
|
|
|
|
"""copora all route"""
|
|
|
|
|
# FIXME rendre ce template dynamique, if faut récuperer les maisons depuis la base
|
|
|
|
|
# FIXME récupérer les maisons depuis la base
|
|
|
|
|
# house_label = ["Bourbon", "Berry", "Anjou"]
|
|
|
|
|
return render_template("corpora_all.html")
|
|
|
|
|
"""copora all
|
|
|
|
|
|
|
|
|
|
lists houses
|
|
|
|
|
sample_house_names = ["Bourbon", "Berry", "Anjou", ...]
|
|
|
|
|
"""
|
|
|
|
|
houses = list(dbhouse.find())
|
|
|
|
|
return render_template("corpora_all.html", houses=houses)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@main.route("/actes/<house>") # dont put a slash at the end
|
|
|
|
|
|