Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
A
account_init_cleanup
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Mitchell Moore
account_init_cleanup
Commits
244b4006
Commit
244b4006
authored
5 years ago
by
Mitchell Moore
Browse files
Options
Downloads
Patches
Plain Diff
get basic form data passed
parent
c271e22e
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
app/__init__.py
+0
-22
0 additions, 22 deletions
app/__init__.py
app/static/scripts/function.js
+4
-42
4 additions, 42 deletions
app/static/scripts/function.js
app/templates/auth/SignUp.html
+42
-12
42 additions, 12 deletions
app/templates/auth/SignUp.html
run.py
+25
-1
25 additions, 1 deletion
run.py
with
71 additions
and
77 deletions
app/__init__.py
+
0
−
22
View file @
244b4006
...
@@ -22,7 +22,6 @@ global time_stamp
...
@@ -22,7 +22,6 @@ global time_stamp
def
create_app
(
config_name
):
def
create_app
(
config_name
):
app
=
Flask
(
__name__
)
# initialization of the flask app
app
=
Flask
(
__name__
)
# initialization of the flask app
Bootstrap
(
app
)
# allowing app to use bootstrap
Bootstrap
(
app
)
# allowing app to use bootstrap
socketio
=
SocketIO
(
app
)
global
return_url
global
return_url
return_url
=
''
return_url
=
''
...
@@ -79,27 +78,6 @@ def create_app(config_name):
...
@@ -79,27 +78,6 @@ def create_app(config_name):
# misc page error catching
# misc page error catching
def
messageReceived
(
methods
=
[
'
GET
'
,
'
POST
'
]):
print
(
'
message was received!!!
'
)
@socketio.on
(
'
user connect
'
)
def
handle_my_custom_event
(
json
,
methods
=
[
'
GET
'
,
'
POST
'
]):
print
(
'
received my event:
'
+
str
(
json
))
@socketio.on
(
'
my event
'
)
def
handle_my_custom_event
(
json
,
methods
=
[
'
GET
'
,
'
POST
'
]):
print
(
'
received my event:
'
+
str
(
json
))
socketio
.
emit
(
'
my response
'
,
json
,
callback
=
messageReceived
)
# time_stamp = time.strftime("%m-%d-%Y_%H:%M:%S")
# complete_file_name = os.path.join(directory, time_stamp + ".txt")
# file = open(complete_file_name, "w")
# file.close()
# time.sleep(5)
#
# pre, ext = os.path.splitext(complete_file_name)
# os.rename(complete_file_name, pre + ".done")
socketio
.
emit
(
'
create response
'
,
json
,
callback
=
messageReceived
)
@app.errorhandler
(
403
)
@app.errorhandler
(
403
)
def
forbidden
(
error
):
def
forbidden
(
error
):
return
render_template
(
'
errors/403.html
'
,
title
=
'
Forbidden
'
),
403
return
render_template
(
'
errors/403.html
'
,
title
=
'
Forbidden
'
),
403
...
...
This diff is collapsed.
Click to expand it.
app/static/scripts/function.js
+
4
−
42
View file @
244b4006
...
@@ -17,46 +17,8 @@ function displayloading() {
...
@@ -17,46 +17,8 @@ function displayloading() {
}
}
function
socketIO
()
{
function
socketIO
()
{
var
socket
=
io
.
connect
(
'
http://
'
+
document
.
domain
+
'
:
'
+
location
.
port
);
socket
.
emit
(
'
user connect
'
,
{
fullname
:
document
.
getElementById
(
"
fullname
"
).
value
,
socket
.
on
(
'
connect
'
,
function
()
{
reason
:
document
.
getElementById
(
"
reason
"
).
value
socket
.
emit
(
'
user connect
'
,
{
})
data
:
'
User Connected
'
}
)
document
.
getElementById
(
"
testo
"
).
innerHTML
=
"
yo
"
var
form
=
$
(
'
form
'
).
on
(
'
submit
'
,
function
(
e
)
{
e
.
preventDefault
()
let
user_name
=
$
(
'
input.username
'
).
val
()
let
user_input
=
$
(
'
input.message
'
).
val
()
socket
.
emit
(
'
my event
'
,
{
user_name
:
user_name
,
message
:
user_input
}
)
$
(
'
input.message
'
).
val
(
''
).
focus
()
}
)
}
)
socket
.
on
(
'
my response
'
,
function
(
msg
)
{
console
.
log
(
msg
)
if
(
typeof
msg
.
user_name
!==
'
undefined
'
)
{
$
(
'
h3
'
).
remove
()
$
(
'
div.message_holder
'
).
append
(
'
<div><b style="color: #002">
'
+
msg
.
user_name
+
'
</b> creating</div>
'
)
}
})
socket
.
on
(
'
create response
'
,
function
(
msg
)
{
console
.
log
(
msg
)
if
(
typeof
msg
.
user_name
!==
'
undefined
'
)
{
$
(
'
h3
'
).
remove
()
$
(
'
div.message_holder
'
).
append
(
'
<div><b style="color: #002">
'
+
msg
.
user_name
+
'
</b> created. WELCOME</div>
'
)
}
})
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
app/templates/auth/SignUp.html
+
42
−
12
View file @
244b4006
...
@@ -5,6 +5,36 @@
...
@@ -5,6 +5,36 @@
<script
src=
"https://cdnjs.cloudflare.com/ajax/libs/socket.io/1.7.3/socket.io.min.js"
></script>
<script
src=
"https://cdnjs.cloudflare.com/ajax/libs/socket.io/1.7.3/socket.io.min.js"
></script>
<script
src=
"static/scripts/function.js"
></script>
<script
src=
"static/scripts/function.js"
></script>
<script
src=
"static/scripts/function.js"
></script>
<script
src=
"static/scripts/function.js"
></script>
<script>
var
socket
=
io
.
connect
(
'
http://
'
+
document
.
domain
+
'
:
'
+
location
.
port
);
socket
.
on
(
'
connect
'
,
function
()
{
socket
.
emit
(
'
user connect
'
,
{
data
:
'
User Connected
'
}
)
socket
.
on
(
'
my response
'
,
function
(
msg
)
{
console
.
log
(
msg
)
if
(
typeof
msg
.
user_name
!==
'
undefined
'
)
{
$
(
'
h3
'
).
remove
()
$
(
'
div.message_holder
'
).
append
(
'
<div><b style="color: #002">
'
+
msg
.
user_name
+
'
</b> creating</div>
'
)
}
})
socket
.
on
(
'
create response
'
,
function
(
msg
)
{
console
.
log
(
msg
)
if
(
typeof
msg
.
user_name
!==
'
undefined
'
)
{
$
(
'
h3
'
).
remove
()
$
(
'
div.message_holder
'
).
append
(
'
<div><b style="color: #002">
'
+
msg
.
user_name
+
'
</b> created. WELCOME</div>
'
)
}
})
})
</script>
<style
type=
"text/css"
>
<style
type=
"text/css"
>
.important
{
color
:
#336699
;
}
.important
{
color
:
#336699
;
}
</style>
</style>
...
@@ -61,20 +91,20 @@
...
@@ -61,20 +91,20 @@
<form
action=
"."
method=
"post"
onsubmit=
""
>
<form
action=
"."
method=
"post"
onsubmit=
""
>
<div
class=
"signUpContainer"
>
<div
class=
"signUpContainer"
>
<label><b><label
for=
"fullname"
>
Full Name:
</label><br></b></label>
<label><b><label
for=
"fullname"
>
Full Name:
</label><br></b></label>
<input
class=
"form-control"
id=
"fullname"
name=
"fullname"
placeholder=
"Enter Full Name"
required=
""
type=
"text"
value=
""
>
<input
class=
"form-control"
id=
"fullname"
name=
"fullname"
placeholder=
"Enter Full Name"
required=
""
type=
"text"
>
<label><b><label
for=
"reason"
>
Reason for Requesting Account:
</label><br></b></label>
<label><b><label
for=
"reason"
>
Reason for Requesting Account:
</label><br></b></label>
<textarea
class=
"form-control"
id=
"reason"
name=
"reason"
placeholder=
"Enter Reason for Account Request"
required=
""
></textarea>
<textarea
class=
"form-control"
id=
"reason"
name=
"reason"
placeholder=
"Enter Reason for Account Request"
required=
""
></textarea>
<input
class=
"btn btn-primary btn-block"
id=
"submit"
name=
"submit"
type=
"button"
value=
"Submit"
onclick=
"displayloading(); socketIO()
;
"
>
<input
class=
"btn btn-primary btn-block"
id=
"submit"
name=
"submit"
type=
"button"
value=
"Submit"
onclick=
"displayloading(); socketIO()"
>
{#
{% with messages = get_flashed_messages() %}
#}
{% with messages = get_flashed_messages() %}
{#
{% if messages %}
#}
{% if messages %}
{#
{% for message in messages %}
#}
{% for message in messages %}
{#
<div>
#}
<div>
{#
<strong
style=
"color: #be051b; text-align: center;"
>
{{ message }}
</strong>
#}
<strong
style=
"color: #be051b; text-align: center;"
>
{{ message }}
</strong>
{#
</div>
#}
</div>
{#
{% endfor %}
#}
{% endfor %}
{#
{% endif %}
#}
{% endif %}
{#
{% endwith %}
#}
{% endwith %}
</div>
</div>
</form>
</form>
...
...
This diff is collapsed.
Click to expand it.
run.py
+
25
−
1
View file @
244b4006
...
@@ -7,10 +7,34 @@ from flask_socketio import SocketIO
...
@@ -7,10 +7,34 @@ from flask_socketio import SocketIO
config_name
=
os
.
getenv
(
'
FLASK_CONFIG
'
)
config_name
=
os
.
getenv
(
'
FLASK_CONFIG
'
)
app
=
create_app
(
config_name
)
app
=
create_app
(
config_name
)
app
.
secret_key
=
'
randomString
'
app
.
config
[
'
SECRET_KEY
'
]
=
'
vnkdjnfjknfl1232#
'
socketio
=
SocketIO
(
app
)
socketio
=
SocketIO
(
app
)
def
messageReceived
(
methods
=
[
'
GET
'
,
'
POST
'
]):
print
(
'
message was received!!!
'
)
@socketio.on
(
'
user connect
'
)
def
handle_my_custom_event
(
json
,
methods
=
[
'
GET
'
,
'
POST
'
]):
print
(
'
received my event:
'
+
str
(
json
))
@socketio.on
(
'
my event
'
)
def
handle_my_custom_event
(
json
,
methods
=
[
'
GET
'
,
'
POST
'
]):
print
(
'
received my event:
'
+
str
(
json
))
socketio
.
emit
(
'
my response
'
,
json
,
callback
=
messageReceived
)
# time_stamp = time.strftime("%m-%d-%Y_%H:%M:%S")
# complete_file_name = os.path.join(directory, time_stamp + ".txt")
# file = open(complete_file_name, "w")
# file.close()
# time.sleep(5)
#
# pre, ext = os.path.splitext(complete_file_name)
# os.rename(complete_file_name, pre + ".done")
socketio
.
emit
(
'
create response
'
,
json
,
callback
=
messageReceived
)
if
__name__
==
'
__main__
'
:
if
__name__
==
'
__main__
'
:
# app.run()
# app.run()
socketio
.
run
(
app
)
socketio
.
run
(
app
)
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