-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathserver.py
33 lines (22 loc) · 803 Bytes
/
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
from flask import Flask, render_template, request
from is_valid_url import is_valid_url
from get_tags_and_count import get_tags_and_count
app = Flask(__name__)
app.secret_key = "inspect_a_website"
@app.route('/', methods=['GET', 'POST'])
def homepage():
if request.method == 'POST':
url = request.form['url']
if not url.startswith("http://") and not url.startswith("https://"):
url = "http://" + url
source_code, msg = is_valid_url(url)
if source_code is None:
url = ""
source_code = ""
tags_and_count = get_tags_and_count(source_code)
return render_template('homepage.html', url=url, msg=msg, \
source_code=source_code, tags_and_count=tags_and_count)
else:
return render_template('homepage.html', tags_and_count={})
if __name__ == "__main__":
app.run(debug=True)