From 0033914918fe313b7213ffb7f55ecacbcf44750d Mon Sep 17 00:00:00 2001 From: Stefano Assenzo Date: Sun, 12 Feb 2023 14:21:42 +0000 Subject: [PATCH] I forgot to put that it shows if le3 is busy or not --- app.py | 8 +- .../api/school_time/api_school_times.py | 9 +- templates/homepage.html | 2 +- templates/orario/orario.html | 152 ++++++++++++++++++ 4 files changed, 159 insertions(+), 12 deletions(-) diff --git a/app.py b/app.py index aa537c7..2b12b5e 100644 --- a/app.py +++ b/app.py @@ -39,11 +39,11 @@ def homepage(): @app.route('/orario') def orario(): logging.info("A user went up: Orario") - url = "http://127.0.0.1:5000" - response = Request(url, headers={"User-Agent": "Mozilla/5.0"}) - webpage = urlopen(response).read() + #url = "http://127.0.0.1:5000" + #response = Request(url, headers={"User-Agent": "Mozilla/5.0"}) + #webpage = urlopen(response).read() # Take all data from mongodb - dict = list(json.loads(webpage)) + dict = list(collection.find({}, {"_id": 0, "School Subject": 1})) number = str(range(0,7)) day = str(["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]) return render_template('orario/orario.html', data=dict, number=number, day=day) diff --git a/subdomains/api/school_time/api_school_times.py b/subdomains/api/school_time/api_school_times.py index dc2446c..c13c573 100644 --- a/subdomains/api/school_time/api_school_times.py +++ b/subdomains/api/school_time/api_school_times.py @@ -1,13 +1,8 @@ -from flask import Flask, render_template, request, redirect, session, url_for, jsonify +from flask import Flask, jsonify from dotenv import load_dotenv from pymongo import MongoClient -import requests import os import urllib -import pymongo -import datetime -import requests -import time app = Flask(__name__) load_dotenv() #Load .env file @@ -26,4 +21,4 @@ def get_subjects(): return jsonify(list(subjects)) if __name__ == '__main__': - app.run() \ No newline at end of file + app.run(debug=True) \ No newline at end of file diff --git a/templates/homepage.html b/templates/homepage.html index fe413b4..99df45a 100644 --- a/templates/homepage.html +++ b/templates/homepage.html @@ -6,5 +6,5 @@

2 Elci

- + Orario scolastico \ No newline at end of file diff --git a/templates/orario/orario.html b/templates/orario/orario.html index 3fa4795..012742c 100644 --- a/templates/orario/orario.html +++ b/templates/orario/orario.html @@ -621,4 +621,156 @@
(Martin) Venerdì (6 ora) le è occupato da: {{ i['School Subject']['Friday'][5]['le is busy']}}
{% endif %} {% endfor %} + {% for i in data %} + {% if i['School Subject']['Monday'][0]['le3 is busy'] == "" %} +
+ {% else %} +
(Martin) Lunedì (1 ora) le3 è occupato da: {{ i['School Subject']['Monday'][0]['le3 is busy']}}
+ {% endif %} + {% if i['School Subject']['Monday'][1]['le3 is busy'] == "" %} +
+ {% else %} +
(Martin) Lunedì (2 ora) le3 è occupato da: {{ i['School Subject']['Monday'][1]['le3 is busy']}}
+ {% endif %} + {% if i['School Subject']['Monday'][2]['le3 is busy'] == "" %} +
+ {% else %} +
(Martin) Lunedì (3 ora) le3 è occupato da: {{ i['School Subject']['Monday'][2]['le3 is busy']}}
+ {% endif %} + {% if i['School Subject']['Monday'][3]['le3 is busy'] == "" %} +
+ {% else %} +
(Martin) Lunedì (4 ora) le3 è occupato da: {{ i['School Subject']['Monday'][3]['le3 is busy']}}
+ {% endif %} + {% if i['School Subject']['Monday'][4]['le3 is busy'] == "" %} +
+ {% else %} +
(Martin) Lunedì (5 ora) le3 è occupato da: {{ i['School Subject']['Monday'][4]['le3 is busy']}}
+ {% endif %} + {% if i['School Subject']['Monday'][5]['le3 is busy'] == "" %} +
+ {% else %} +
(Martin) Lunedì (6 ora) le3 è occupato da: {{ i['School Subject']['Monday'][5]['le3 is busy']}}
+ {% endif %} + {% if i['School Subject']['Tuesday'][0]['le3 is busy'] == "" %} +
+ {% else %} +
(Martin) Martedì (1 ora) le3 è occupato da: {{ i['School Subject']['Tuesday'][0]['le3 is busy']}}
+ {% endif %} + {% if i['School Subject']['Tuesday'][1]['le3 is busy'] == "" %} +
+ {% else %} +
(Martin) Martedì (2 ora) le3 è occupato da: {{ i['School Subject']['Tuesday'][1]['le3 is busy']}}
+ {% endif %} + {% if i['School Subject']['Tuesday'][2]['le3 is busy'] == "" %} +
+ {% else %} +
(Martin) Martedì (3 ora) le3 è occupato da: {{ i['School Subject']['Tuesday'][2]['le3 is busy']}}
+ {% endif %} + {% if i['School Subject']['Tuesday'][3]['le3 is busy'] == "" %} +
+ {% else %} +
(Martin) Martedì (4 ora) le3 è occupato da: {{ i['School Subject']['Tuesday'][3]['le3 is busy']}}
+ {% endif %} + {% if i['School Subject']['Tuesday'][4]['le3 is busy'] == "" %} +
+ {% else %} +
(Martin) Martedì (5 ora) le3 è occupato da: {{ i['School Subject']['Tuesday'][4]['le3 is busy']}}
+ {% endif %} + {% if i['School Subject']['Tuesday'][5]['le3 is busy'] == "" %} +
+ {% else %} +
(Martin) Martedì (6 ora) le3 è occupato da: {{ i['School Subject']['Tuesday'][5]['le3 is busy']}}
+ {% endif %} + {% if i['School Subject']['Wednesday'][0]['le3 is busy'] == "" %} +
+ {% else %} +
(Martin) Mercoledì (1 ora) le3 è occupato da: {{ i['School Subject']['Wednesday'][0]['le3 is busy']}}
+ {% endif %} + {% if i['School Subject']['Wednesday'][1]['le3 is busy'] == "" %} +
+ {% else %} +
(Martin) Mercoledì (2 ora) le3 è occupato da: {{ i['School Subject']['Wednesday'][1]['le3 is busy']}}
+ {% endif %} + {% if i['School Subject']['Wednesday'][2]['le3 is busy'] == "" %} +
+ {% else %} +
(Martin) Mercoledì (3 ora) le3 è occupato da: {{ i['School Subject']['Wednesday'][2]['le3 is busy']}}
+ {% endif %} + {% if i['School Subject']['Wednesday'][3]['le3 is busy'] == "" %} +
+ {% else %} +
(Martin) Mercoledì (4 ora) le3 è occupato da: {{ i['School Subject']['Wednesday'][3]['le3 is busy']}}
+ {% endif %} + {% if i['School Subject']['Wednesday'][4]['le3 is busy'] == "" %} +
+ {% else %} +
(Martin) Mercoledì (5 ora) le3 è occupato da: {{ i['School Subject']['Wednesday'][4]['le3 is busy']}}
+ {% endif %} + {% if i['School Subject']['Wednesday'][5]['le3 is busy'] == "" %} +
+ {% else %} +
(Martin) Mercoledì (6 ora) le3 è occupato da: {{ i['School Subject']['Wednesday'][5]['le3 is busy']}}
+ {% endif %} + {% if i['School Subject']['Thursday'][0]['le3 is busy'] == "" %} +
+ {% else %} +
(Martin) Giovedì (1 ora) le3 è occupato da: {{ i['School Subject']['Thursday'][0]['le3 is busy']}}
+ {% endif %} + {% if i['School Subject']['Thursday'][1]['le3 is busy'] == "" %} +
+ {% else %} +
(Martin) Giovedì (2 ora) le3 è occupato da: {{ i['School Subject']['Thursday'][1]['le3 is busy']}}
+ {% endif %} + {% if i['School Subject']['Thursday'][2]['le3 is busy'] == "" %} +
+ {% else %} +
(Martin) Giovedì (3 ora) le3 è occupato da: {{ i['School Subject']['Thursday'][2]['le3 is busy']}}
+ {% endif %} + {% if i['School Subject']['Thursday'][3]['le3 is busy'] == "" %} +
+ {% else %} +
(Martin) Giovedì (4 ora) le3 è occupato da: {{ i['School Subject']['Thursday'][3]['le3 is busy']}}
+ {% endif %} + {% if i['School Subject']['Thursday'][4]['le3 is busy'] == "" %} +
+ {% else %} +
(Martin) Giovedì (5 ora) le3 è occupato da: {{ i['School Subject']['Thursday'][4]['le3 is busy']}}
+ {% endif %} + {% if i['School Subject']['Thursday'][5]['le3 is busy'] == "" %} +
+ {% else %} +
(Martin) Giovedì (6 ora) le3 è occupato da: {{ i['School Subject']['Thursday'][5]['le3 is busy']}}
+ {% endif %} + {% if i['School Subject']['Friday'][0]['le3 is busy'] == "" %} +
+ {% else %} +
(Martin) Venerdì (1 ora) le3 è occupato da: {{ i['School Subject']['Friday'][0]['le3 is busy']}}
+ {% endif %} + {% if i['School Subject']['Friday'][1]['le3 is busy'] == "" %} +
+ {% else %} +
(Martin) Venerdì (2 ora) le3 è occupato da: {{ i['School Subject']['Friday'][1]['le3 is busy']}}
+ {% endif %} + {% if i['School Subject']['Friday'][2]['le3 is busy'] == "" %} +
+ {% else %} +
(Martin) Venerdì (3 ora) le3 è occupato da: {{ i['School Subject']['Friday'][2]['le3 is busy']}}
+ {% endif %} + {% if i['School Subject']['Friday'][3]['le3 is busy'] == "" %} +
+ {% else %} +
(Martin) Venerdì (4 ora) le3 è occupato da: {{ i['School Subject']['Friday'][3]['le3 is busy']}}
+ {% endif %} + {% if i['School Subject']['Friday'][4]['le3 is busy'] == "" %} +
+ {% else %} +
(Martin) Venerdì (5 ora) le3 è occupato da: {{ i['School Subject']['Friday'][4]['le3 is busy']}}
+ {% endif %} + {% if i['School Subject']['Friday'][5]['le3 is busy'] == "" %} +
+ {% else %} +
(Martin) Venerdì (6 ora) le3 è occupato da: {{ i['School Subject']['Friday'][5]['le3 is busy']}}
+ {% endif %} + {% endfor %} \ No newline at end of file