diff --git a/api/app.py b/api/app.py deleted file mode 100644 index f3fea3a..0000000 --- a/api/app.py +++ /dev/null @@ -1,73 +0,0 @@ -from flask import Flask, render_template, request, redirect, session, url_for, jsonify -from dotenv import load_dotenv -import requests -import os -import urllib -import pymongo - -app = Flask(__name__) - -load_dotenv() #Load .env file -PASSWORD_MONGODB = os.getenv('PASSWORD_MONGODB') #Password for MongoDB -URL_MONGODB = os.getenv('URL_MONGODB') #URL for MongoDB -mongo_url = "mongodb+srv://elci:" + urllib.parse.quote_plus(PASSWORD_MONGODB) + URL_MONGODB #URL for MongoDB (with password) -client = pymongo.MongoClient(mongo_url) #Connect to MongoDB -database = client["website-class"] #Database name -collection = database["school-time-table"] - -@app.route('/', methods = ['GET', 'POST']) -def api(): - if(request.method == 'GET'): - collection_find_username = list(collection.find({}, {"School Subject": 1,})) - array_username = collection_find_username[0]['School Subject'] - - - test = { - "subject" : { - "monday": { - "Subject 1": array_username[0], - "Subject 2": array_username[1], - "Subject 3": array_username[2], - "Subject 4": array_username[3], - "Subject 5": array_username[4], - "Subject 6": array_username[5], - }, - "tuesday": { - "Subject 1": array_username[6], - "Subject 2": array_username[7], - "Subject 3": array_username[8], - "Subject 4": array_username[9], - "Subject 5": array_username[10], - "Subject 6": array_username[11], - }, - "wednesday": { - "Subject 1": array_username[12], - "Subject 2": array_username[13], - "Subject 3": array_username[14], - "Subject 4": array_username[15], - "Subject 5": array_username[16], - "Subject 6": array_username[17], - }, - "thursday": { - "Subject 1": array_username[18], - "Subject 2": array_username[19], - "Subject 3": array_username[20], - "Subject 4": array_username[21], - "Subject 5": array_username[22], - "Subject 6": array_username[23], - }, - "friday": { - "Subject 1": array_username[24], - "Subject 2": array_username[25], - "Subject 3": array_username[26], - "Subject 4": array_username[27], - "Subject 5": array_username[28], - "Subject 6": array_username[29], - } - } - } - - return jsonify(test) - -if __name__ == '__main__': - app.run() \ No newline at end of file diff --git a/src/events/update_time_school.py b/src/events/update_time_school.py index 7e087f3..fb7796b 100644 --- a/src/events/update_time_school.py +++ b/src/events/update_time_school.py @@ -23,15 +23,17 @@ current_time = datetime.datetime.now() day = str(current_time.day) month = str(current_time.month) year = str(current_time.year) -si = day + "-" + month + "-" + year +hour = str(current_time.hour) +minute = str(current_time.minute) +second = str(current_time.second) +long_date = day + "-" + month + "-" + year + " " + hour + ":" + minute + ":" + second mydict = { - "Date": si, + "Date": long_date, "School Subject": [], "Teacher": [], } x = collection.insert_one(mydict) -# row 4 for row in range (1, 100): # column B ~ column F for column in range (1, 100): @@ -42,7 +44,7 @@ for row in range (1, 100): for i in range(4,80): school_subject = ws.cell(row=i, column=column).value if school_subject == 0: - find_document_username = list(collection.find({}, {"Date": si})) + find_document_username = list(collection.find({}, {"Date": long_date})) array_username = find_document_username[0]["_id"] collection.update_one( { "_id": ObjectId(array_username)}, @@ -51,7 +53,7 @@ for row in range (1, 100): }) else: remove_things_in_front = school_subject.split(' ', 1)[1] - find_document_username = list(collection.find({}, {"Date": si})) + find_document_username = list(collection.find({}, {"Date": long_date})) array_username = find_document_username[0]["_id"] collection.update_one( { "_id": ObjectId(array_username)}, @@ -66,7 +68,7 @@ for row in range (1, 100): if teacher == 0: pass else: - find_document_username = list(collection.find({}, {"Date": si})) + find_document_username = list(collection.find({}, {"Date": long_date})) array_username = find_document_username[0]["_id"] collection.update_one( { "_id": ObjectId(array_username)}, diff --git a/static/css/a.css b/static/css/a.css deleted file mode 100644 index 07b184a..0000000 --- a/static/css/a.css +++ /dev/null @@ -1,16 +0,0 @@ -.orario { - padding-top: 300px; - text-align: center; -} -html, body { - margin:0; - padding:0; -} -.background { - position: absolute; - display: block; - top: 0; - left: 0; - z-index:0; - color: black; -} \ No newline at end of file diff --git a/static/images/assets/calendario_logo.png b/static/images/assets/calendario_logo.png deleted file mode 100644 index 7bcb2f0..0000000 Binary files a/static/images/assets/calendario_logo.png and /dev/null differ diff --git a/static/images/assets/logo.png b/static/images/assets/logo.png deleted file mode 100644 index 5fd234c..0000000 Binary files a/static/images/assets/logo.png and /dev/null differ diff --git a/static/images/assets/orario_logo.png b/static/images/assets/orario_logo.png deleted file mode 100644 index af681ad..0000000 Binary files a/static/images/assets/orario_logo.png and /dev/null differ diff --git a/subdomains/api/app.py b/subdomains/api/app.py new file mode 100644 index 0000000..6153414 --- /dev/null +++ b/subdomains/api/app.py @@ -0,0 +1,81 @@ +from flask import Flask, render_template, request, redirect, session, url_for, jsonify +from dotenv import load_dotenv +import requests +import os +import urllib +import pymongo +import datetime +import requests +import time + +app = Flask(__name__) + +load_dotenv() #Load .env file +PASSWORD_MONGODB = os.getenv('PASSWORD_MONGODB') #Password for MongoDB +URL_MONGODB = os.getenv('URL_MONGODB') #URL for MongoDB +mongo_url = "mongodb+srv://elci:" + urllib.parse.quote_plus(PASSWORD_MONGODB) + URL_MONGODB #URL for MongoDB (with password) +client = pymongo.MongoClient(mongo_url) #Connect to MongoDB +database = client["website-class"] #Database name +collection = database["school-time-table"] + +@app.route('/', methods = ['GET', 'POST']) +def api(): + current_time = datetime.datetime.now() + day = str(current_time.day) + month = str(current_time.month) + year = str(current_time.year) + hour = str(current_time.hour) + minute = str(current_time.minute) + long_date = day + "-" + month + "-" + year + hour + ":" + minute + collection_find_username = list(collection.find({}, {"Date": long_date ,"School Subject": 1,})) + array_username = collection_find_username[0]['School Subject'] + + test = { + "subject" : { + "monday": { + "Subject 1": array_username[0], + "Subject 2": array_username[1], + "Subject 3": array_username[2], + "Subject 4": array_username[3], + "Subject 5": array_username[4], + "Subject 6": array_username[5], + }, + "tuesday": { + "Subject 1": array_username[14], + "Subject 2": array_username[15], + "Subject 3": array_username[16], + "Subject 4": array_username[17], + "Subject 5": array_username[18], + "Subject 6": array_username[19], + }, + "wednesday": { + "Subject 1": array_username[12], + "Subject 2": array_username[13], + "Subject 3": array_username[14], + "Subject 4": array_username[15], + "Subject 5": array_username[16], + "Subject 6": array_username[17], + }, + "thursday": { + "Subject 1": array_username[28], + "Subject 2": array_username[29], + "Subject 3": array_username[30], + "Subject 4": array_username[31], + "Subject 5": array_username[32], + "Subject 6": array_username[33], + }, + "friday": { + "Subject 1": array_username[42], + "Subject 2": array_username[43], + "Subject 3": array_username[44], + "Subject 4": array_username[45], + "Subject 5": array_username[46], + "Subject 6": array_username[47], + } + } + } + + return jsonify(test) + +if __name__ == '__main__': + app.run() \ No newline at end of file diff --git a/templates/html/calendario.html b/templates/html/calendario.html deleted file mode 100644 index 5ec6300..0000000 --- a/templates/html/calendario.html +++ /dev/null @@ -1,10 +0,0 @@ - - -
- -Hello World!