Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
TDDD97 Web Programming
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Lawrence Zawahri
TDDD97 Web Programming
Commits
dd07b92b
Commit
dd07b92b
authored
3 years ago
by
Lawrence Zawahri
Browse files
Options
Downloads
Patches
Plain Diff
lab 3 working on bug ficx
parent
cd7927bc
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Lab_3/Twidder/server.py
+22
-5
22 additions, 5 deletions
Lab_3/Twidder/server.py
Lab_3/Twidder/static/client.js
+1
-2
1 addition, 2 deletions
Lab_3/Twidder/static/client.js
with
23 additions
and
7 deletions
Lab_3/Twidder/server.py
+
22
−
5
View file @
dd07b92b
...
...
@@ -85,19 +85,36 @@ def echo(socket):
return
# sign out if I am logged in somewhere else
print
(
"
Before loop
"
)
print
(
"
/n
"
)
print
(
session
)
print
(
"
/n
"
)
for
token
in
list
(
session
.
keys
()):
if
session
[
token
][
0
]
==
myEmail
and
token
!=
myToken
:
if
session
[
token
][
1
]
!=
""
:
session
[
token
][
1
].
send
(
json
.
dumps
({
"
action
"
:
"
signOut
"
}))
session
[
token
][
1
].
close
()
if
session
[
token
][
0
]
==
myEmail
and
token
!=
myToken
and
session
[
token
][
1
]
!=
""
:
print
(
"
Inside first if
"
)
#if session[token][1] != "":
print
(
"
Inside second if
"
)
session
[
token
][
1
].
send
(
json
.
dumps
({
"
action
"
:
"
signOut
"
}))
print
(
token
[
1
])
session
[
token
][
1
].
close
()
print
(
"
You got kicked out
"
)
session
.
pop
(
token
)
print
(
"
After loop
"
)
print
(
"
/n
"
)
print
(
session
)
print
(
"
/n
"
)
# Put socket in global dict so server knows my connection is open
session
[
myToken
]
=
(
myEmail
,
socket
)
print
(
"
After insertion into dict
"
)
print
(
"
/n
"
)
print
(
session
)
print
(
"
/n
"
)
socket
.
send
(
json
.
dumps
({
"
action
"
:
"
signIn
"
}))
...
...
@@ -123,7 +140,7 @@ def sign_in():
return
jsonify
({}),
404
#"No user found by your email"
if
password
!=
rows
[
1
]:
return
jsonify
({}),
401
#"Incorrect password")
return
jsonify
({}),
401
#"Incorrect password")
x
# Generate a random token
token
=
str
(
uuid
.
uuid4
())
...
...
This diff is collapsed.
Click to expand it.
Lab_3/Twidder/static/client.js
+
1
−
2
View file @
dd07b92b
...
...
@@ -17,7 +17,6 @@ function connectWithSocket() {
displayView
();
setUserDetails
(
"
home
"
);
// Establish web socket
socket
=
new
WebSocket
(
'
ws://
'
+
document
.
domain
+
'
:5000/myServer/api
'
);
...
...
@@ -37,7 +36,7 @@ function connectWithSocket() {
case
"
signOut
"
:
// If old socket open, close it.
socket
.
close
();
//
socket.close();
console
.
log
(
response
);
// Reset token in the localStorage
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment