diff --git a/app.py b/app.py index d67f806..f52c4e0 100644 --- a/app.py +++ b/app.py @@ -63,6 +63,19 @@ def serviceList(): return render_template("serviceList.html", serviceInfo=dictService) +@app.route("/request") +def requestServie(): + serviceName = request.args.get('service-name', "") + url = request.args.get('url', "") + info = request.args.get('info', "") + + if len(serviceName) > 0: + # If someone wrote in the form + dataReport.newRequest(serviceName, url, info) + + + return render_template("request.html") + # To handle error reporting @app.route('/process', methods=['GET']) def process(): @@ -100,7 +113,7 @@ def page_not_found(error): def extractLog(): get_what_to_extract = request.args.get("get") - if get_what_to_extract in services.keys(): + if get_what_to_extract in services.keys() or get_what_to_extract == "request": with open("data/" + get_what_to_extract + "/log.csv", "r") as file: csv_data = list(csv.reader(file, delimiter=",")) diff --git a/data/request/log.csv b/data/request/log.csv new file mode 100644 index 0000000..5f80c19 --- /dev/null +++ b/data/request/log.csv @@ -0,0 +1,2 @@ +time,service,url,reason +2024-01-22T20:41:15,LEPL1201,https://perso.uclouvain.be/vincent.legat/zouLab/epl1201.php,pilou-pilou \ No newline at end of file diff --git a/dataReport.py b/dataReport.py index 67d4d7c..11dd6e5 100644 --- a/dataReport.py +++ b/dataReport.py @@ -105,6 +105,9 @@ def addReport(service, user_choice): def dataExtraction(): + # To get User's request + os.system(f'cmd /c "curl {url}/extract?get=request -o data/request/log.csv"') + for service in serviceList: os.system(f'cmd /c "curl {url}/extract?get={service} -o data/{service}/log.csv"') @@ -120,5 +123,13 @@ def getLastReport(service): return True return None +def newRequest(serviceName, url, info): + date = datetime.now(pytz.utc).strftime(jsonUtility.datetimeFormat) + log = "data/request/log.csv" + + with open(log, "a") as file: + file.write(date + "," + serviceName + "," + url + "," + info) + + if __name__ == "__main__": dataExtraction() \ No newline at end of file diff --git a/services.json b/services.json index bac665d..aaa6b62 100644 --- a/services.json +++ b/services.json @@ -1,46 +1,46 @@ { "404-Test": { - "Last access time": "2024-01-22T19:09:37", + "Last access time": "2024-01-22T20:42:03", "Last status": false, "url": "https://www.google.com/404" }, "ADE": { - "Last access time": "2024-01-22T19:10:04", + "Last access time": "2024-01-22T20:28:47", "Last status": true, "url": "https://horaire.uclouvain.be/direct/" }, "ADE-Scheduler": { - "Last access time": "2024-01-22T19:09:37", + "Last access time": "2024-01-22T20:42:03", "Last status": true, "url": "https://ade-scheduler.info.ucl.ac.be/calendar/" }, "Comproved": { - "Last access time": "2024-01-22T19:09:37", + "Last access time": "2024-01-22T20:42:03", "Last status": true, "url": "https://app.comproved.com/universite-de-louvain" }, "Gradescope": { - "Last access time": "2024-01-22T19:09:38", + "Last access time": "2024-01-22T20:42:04", "Last status": true, "url": "https://www.gradescope.com/" }, "Intranet": { - "Last access time": "2024-01-22T19:09:38", + "Last access time": "2024-01-22T20:42:04", "Last status": true, "url": "https://intranet.uclouvain.be" }, "Moodle": { - "Last access time": "2024-01-22T19:09:38", + "Last access time": "2024-01-22T20:42:04", "Last status": true, "url": "https://moodle.uclouvain.be/" }, "Pilou-Pilou": { - "Last access time": "2024-01-22T19:09:38", + "Last access time": "2024-01-22T20:42:04", "Last status": false, "url": "https://perso.uclouvain.be/vincent.legat/zoulab/" }, "UCLouvain": { - "Last access time": "2024-01-22T19:09:39", + "Last access time": "2024-01-22T20:42:05", "Last status": true, "url": "https://www.uclouvain.be/" } diff --git a/static/main.css b/static/main.css index 59c225b..df228c5 100644 --- a/static/main.css +++ b/static/main.css @@ -30,6 +30,7 @@ body { a.header-button{ color: white; + text-decoration: none; } .header-button:hover{ diff --git a/static/styleRequest.css b/static/styleRequest.css new file mode 100644 index 0000000..759e85c --- /dev/null +++ b/static/styleRequest.css @@ -0,0 +1,40 @@ +#info{ + height: 200px; +} + +form{ + padding: 20px; +} + +label{ + font-size: 25px; + font-weight: bold; +} + +input, textarea{ + background-color: lightgray; + width: 20%; + border-style: none; + + font-size: 20px; + + border-radius: 10px; + margin: 10px; + padding: 10px; +} + +textarea{ + resize: none; + font-size: 15px; +} + +#submit{ + background-color: rgb(144, 145, 150); + width: 10%; + +} + +#submit:hover{ + background-color: rgb(114, 110, 110); + cursor: pointer; +} \ No newline at end of file diff --git a/templates/base.html b/templates/base.html index c4407d6..1d2e5eb 100644 --- a/templates/base.html +++ b/templates/base.html @@ -31,6 +31,7 @@ + {% block content %} diff --git a/templates/request.html b/templates/request.html new file mode 100644 index 0000000..1fde627 --- /dev/null +++ b/templates/request.html @@ -0,0 +1,22 @@ +{% extends "base.html" %} +{% block head %} +