Skip to content

Commit

Permalink
Handling request from User
Browse files Browse the repository at this point in the history
  • Loading branch information
Tfloow committed Jan 22, 2024
1 parent 9c0e9f6 commit dec1b3b
Show file tree
Hide file tree
Showing 8 changed files with 100 additions and 10 deletions.
15 changes: 14 additions & 1 deletion app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down Expand Up @@ -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=","))

Expand Down
2 changes: 2 additions & 0 deletions data/request/log.csv
Original file line number Diff line number Diff line change
@@ -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
11 changes: 11 additions & 0 deletions dataReport.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"')

Expand All @@ -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()
18 changes: 9 additions & 9 deletions services.json
Original file line number Diff line number Diff line change
@@ -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/"
}
Expand Down
1 change: 1 addition & 0 deletions static/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ body {

a.header-button{
color: white;
text-decoration: none;
}

.header-button:hover{
Expand Down
40 changes: 40 additions & 0 deletions static/styleRequest.css
Original file line number Diff line number Diff line change
@@ -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;
}
1 change: 1 addition & 0 deletions templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
<a href="/"><span class="header-button"> <b>Home</b> </span></a>
<a href="https://github.com/Tfloow/UCLouvainDown"><span class="header-button"> <b>Github</b> </span></a>
<a href="/serviceList"><span class="header-button"> <b>ServiceList</b> </span></a>
<a href="/request"><span class="header-button"> <b>Request Service</b> </span></a>
</div>

{% block content %}
Expand Down
22 changes: 22 additions & 0 deletions templates/request.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{% extends "base.html" %}
{% block head %}
<title>Request</title>
<link rel="stylesheet" href="{{ url_for('static', filename='styleRequest.css') }}">
<link rel="icon" type="image/x-icon" href="/static/ico/icoDOWN.png">
<link rel="stylesheet" href="{{ url_for('static', filename='styleServiceList.css') }}">
{% endblock %}

{% block content%}
<form>
<label for="service-name">Service Name:</label><br>
<input type="text" id="service-name" name="service-name"><br>

<label for="url">Service's URL:</label><br>
<input type="url" id="url" name="url"><br>

<label for="info">Extra Info:</label><br>
<textarea id="info" name="info" rows="4" cols="50"></textarea><br>

<input type="submit" value="Submit" id="submit">
</form>
{% endblock %}

0 comments on commit dec1b3b

Please sign in to comment.