-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.py
42 lines (39 loc) · 1.1 KB
/
server.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
from flask import Flask
app = Flask(__name__)
@app.route("/")
def hello():
page = ""
images = ""
other = ""
imagesCounter = 0
otherCounter = 0
other += "<ul>"
images += "<ul>"
with open("interesting_file.txt","r") as f:
for line in f:
if ".jpg" in line.lower() or ".gif" in line.lower():
images += "<li>"
images += "<a href='" + line+ "'>"
images += line
images += "</a></li>"
imagesCounter += 1
else:
other += "<li>"
other += "<a href='" + line + "'>"
other += line
other += "</a></li>"
otherCounter += 1
other += "</ul>"
images += "</ul>"
page += "<table><tr><td>Images</td><td>other</td></tr>"
page += "<tr><td>"
page += str(imagesCounter)
page += "</td><td>"
page += str(otherCounter)
page += "</td></tr>"
page += "<tr><td>"
page += images
page += "</td><td style='vertical-align: top;'>"
page += other
page += "</td></tr></table>"
return page