-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.py
44 lines (35 loc) · 984 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
34
35
36
37
38
39
40
41
42
43
44
from flask import Flask, request, url_for, redirect, render_template
from pprint import pprint
app = Flask(__name__, static_url_path='')
bigLoginObj = [
{
'username': 'admin',
'password': 'default'
},
{
'username': 'nimda',
'password': 'password'
}
]
@app.route('/')
def serve():
return app.send_static_file('map.html')
@app.route('/login')
def login():
return render_template('login.html')
@app.route('/authenticate', methods=['GET', 'POST'])
def authenticate():
error = None
if request.method == 'POST':
for user in bigLoginObj:
if user['username'] == request.form['username'] and user['password'] == request.form['password']:
return redirect(url_for('serve'))
else:
error = ''
return render_template('login.html', error=error)
if __name__ == '__main__':
app.run(
# debug = True,
host="localhost",
port=int("8000")
)