Skip to content

Commit 1940f9d

Browse files
committed
Initial Commit
Initial Commit Application added
0 parents  commit 1940f9d

File tree

122 files changed

+16953
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

122 files changed

+16953
-0
lines changed

.DS_Store

10 KB
Binary file not shown.

index.html

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<title>Login 08</title>
5+
<meta charset="utf-8">
6+
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
7+
8+
<link href="https://fonts.googleapis.com/css?family=Lato:300,400,700&display=swap" rel="stylesheet">
9+
10+
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
11+
12+
<link rel="stylesheet" href="css/style.css">
13+
14+
</head>
15+
<body>
16+
<section class="ftco-section">
17+
<div class="container">
18+
<div class="row justify-content-center">
19+
<div class="col-md-6 text-center mb-5">
20+
<h2 class="heading-section">Login #08</h2>
21+
</div>
22+
</div>
23+
<div class="row justify-content-center">
24+
<div class="col-md-6 col-lg-5">
25+
<div class="login-wrap p-4 p-md-5">
26+
<div class="icon d-flex align-items-center justify-content-center">
27+
<span class="fa fa-user-o"></span>
28+
</div>
29+
<h3 class="text-center mb-4">Have an account?</h3>
30+
<form action="#" class="login-form">
31+
<div class="form-group">
32+
<input type="text" class="form-control rounded-left" placeholder="Username" required>
33+
</div>
34+
<div class="form-group d-flex">
35+
<input type="password" class="form-control rounded-left" placeholder="Password" required>
36+
</div>
37+
<div class="form-group d-md-flex">
38+
<div class="w-50">
39+
<label class="checkbox-wrap checkbox-primary">Remember Me
40+
<input type="checkbox" checked>
41+
<span class="checkmark"></span>
42+
</label>
43+
</div>
44+
<div class="w-50 text-md-right">
45+
<a href="#">Forgot Password</a>
46+
</div>
47+
</div>
48+
<div class="form-group">
49+
<button type="submit" class="btn btn-primary rounded submit p-3 px-5">Get Started</button>
50+
</div>
51+
</form>
52+
</div>
53+
</div>
54+
</div>
55+
</div>
56+
</section>
57+
58+
<script src="js/jquery.min.js"></script>
59+
<script src="js/popper.js"></script>
60+
<script src="js/bootstrap.min.js"></script>
61+
<script src="js/main.js"></script>
62+
63+
</body>
64+
</html>
65+

main.html

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<a href="https://colorlib.com/wp/templates/"><img src="https://colorlib.com/wp/wp-content/uploads/sites/2/colorlib-push-logo.png" alt="Colorlib logo"></a>
2+
<h1 style="text-align:center;">Thank you for using our template!</h1>
3+
<p style="text-align:center;">For more awesome templates please visit <strong><a href="https://colorlib.com/wp/templates/">Colorlib</a></strong>.</p>
4+
5+
<style>
6+
img {
7+
margin: 0 auto;
8+
display: block;
9+
margin-top: 20%;
10+
}
11+
</style>

main.py

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
from flask import Flask, render_template, request, redirect, url_for, jsonify, json, session
2+
from flask_socketio import SocketIO, emit
3+
import requests
4+
5+
app = Flask(__name__)
6+
app.config['SECRET_KEY'] = 'your-secret-key'
7+
socketio = SocketIO(app, engineio_logger=True, cors_allowed_origins='*')
8+
9+
# Store the mapping of clients and their names
10+
clients = {}
11+
12+
photo = ''
13+
username = ''
14+
15+
@app.route('/', methods=['GET', 'POST'])
16+
def login():
17+
if request.method == 'POST':
18+
form_username = request.form['username']
19+
form_password = request.form['password']
20+
21+
if form_username == '' and form_password == '':
22+
return """<script>
23+
alert('Error')
24+
</script>"""
25+
else:
26+
27+
url = f"http://hris.teamglac.com/api/users/login?u={form_username}&p={form_password}"
28+
response = requests.get(url).json()
29+
30+
if response['result'] == False:
31+
return """<script>
32+
alert('Error')
33+
</script>"""
34+
else:
35+
user_data = response["result"]
36+
session['fullname'] = user_data['fullname']
37+
global username
38+
username = session['fullname'] = user_data['fullname']
39+
photo_url = session['photo_url'] = user_data['photo_url']
40+
41+
global photo
42+
if photo_url == False:
43+
photo = """/assets/images/pngegg.png"""
44+
else:
45+
hris = "http://hris.teamglac.com/"
46+
session['photo_url'] = hris + user_data['photo_url']
47+
photo = session['photo_url'] = hris + user_data['photo_url']
48+
return redirect(url_for('index', success=True))
49+
50+
else:
51+
# Display the login form
52+
return render_template('login-auth.html')
53+
54+
@app.route('/index')
55+
def index():
56+
return render_template('chat.html', fullname_var=session['fullname'], photo=photo)
57+
58+
@app.route('/logout')
59+
def logout():
60+
# Clear the session and redirect to the login page
61+
session.clear()
62+
return redirect(url_for('login', success=True))
63+
64+
@socketio.on('connect')
65+
def handle_connect():
66+
if 'fullname' in session:
67+
fullname_var = session['fullname']
68+
photo = session['photo_url']
69+
socketio.emit('handle_data', {'fullname_var': fullname_var, 'photo': photo})
70+
print('Client connected:', fullname_var)
71+
72+
@socketio.on('disconnect')
73+
def handle_disconnect():
74+
if request.sid in clients:
75+
del clients[request.sid]
76+
print('Client disconnected')
77+
78+
@socketio.on('message')
79+
def handle_message(data):
80+
sender_name = clients.get(request.sid)
81+
print('sender data', sender_name)
82+
photo_var = session['photo_url']
83+
sender_name_here = session['fullname']
84+
is_sender = sender_name == session['fullname']
85+
emit('message', {'sender': sender_name_here, 'message': data['message'], 'is_sender': is_sender, 'photo_var': photo_var}, broadcast=True)
86+
87+
@socketio.on('join')
88+
def handle_join(data):
89+
clients[request.sid] = data['name']
90+
emit('join', {'message': f'{data["name"]} has joined the chat'}, broadcast=True)
91+
92+
if __name__ == '__main__':
93+
socketio.run(app, host='10.0.2.150', port='5000', debug=True)

static/assets/css/.DS_Store

6 KB
Binary file not shown.

static/assets/css/bootstrap.min.css

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

static/assets/css/bootstrap/.DS_Store

6 KB
Binary file not shown.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
.media {
2+
display: -webkit-box;
3+
display: -ms-flexbox;
4+
display: flex;
5+
-webkit-box-align: start;
6+
-ms-flex-align: start;
7+
align-items: flex-start; }
8+
9+
.media-body {
10+
-webkit-box-flex: 1;
11+
-ms-flex: 1;
12+
flex: 1; }
Binary file not shown.

static/assets/css/bootstrap/mixins/_border-radius.css

Whitespace-only changes.

0 commit comments

Comments
 (0)