FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
cloudfire/python/example_app.py at master · phonglanpls/cloudfire · GitHub
phonglanpls
/
cloudfire
Public
forked from
coinkite/cloudfire
Notifications
You must be signed in to change notification settings
Fork
0
Star
1
Code
Pull requests
0
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
cloudfire
/
python
/
example_app.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
61 lines (44 loc) · 1.3 KB
Breadcrumbs
cloudfire
/
python
/
example_app.py
Copy path
File metadata and controls
61 lines (44 loc) · 1.3 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
55
56
57
import
time
from
flask
import
request
,
Response
,
render_template
,
json
from
cfcapp
import
CFCFlask
app
=
CFCFlask
(
__name__
)
@
app
.
ws_rx_handler
def
rx_data
(
vhost
,
conn
,
msg
):
say
=
msg
[
'say'
]
m
=
{
'from'
:
conn
.
fid
[
-
8
:].
upper
(),
'content'
:
say
}
app
.
tx
(
m
,
bcast
=
True
)
class
Robot
(
object
):
" Just a super-simple robot "
def
__init__
(
self
):
self
.
heard
=
set
()
@
app
.
background_task
def
robot1
():
while
1
:
say
=
"I'm a robot and the time is %s"
%
time
.
strftime
(
'%T'
)
m
=
{
'from'
:
'Robot1'
,
'content'
:
say
}
app
.
tx
(
m
,
bcast
=
True
)
time
.
sleep
(
15
)
@
app
.
ws_rx_handler
def
rx_data
(
vhost
,
conn
,
msg
):
said
=
msg
[
'say'
]
if
'robot'
in
said
:
return
user
=
conn
.
fid
[
-
8
:].
upper
()
if
user
not
in
self
.
heard
:
m
=
{
'from'
:
'Robot1'
,
'content'
:
"Hello %s. Looking good!"
%
user
}
app
.
tx
(
m
,
bcast
=
True
)
self
.
heard
.
add
(
user
)
Robot
()
@
app
.
route
(
'/'
)
def
ws_test
():
return
render_template
(
"chat.html"
,
vhost
=
request
.
host
)
@
app
.
route
(
'/debug'
)
@
app
.
route
(
'/debug/<path:whatever>'
)
def
hello_world
(
whatever
=
None
):
from
pprint
import
pformat
r
=
pformat
(
request
.
environ
)
r
+=
"
\n
\n
"
r
+=
pformat
(
request
.
environ
[
'werkzeug.request'
].
__class__
.
__module__
)
r
+=
"
\n
\n
"
r
+=
"URL path: %s
\n
\n
"
%
request
.
path
r
+=
"URL: %s"
%
request
.
url
return
Response
(
r
,
mimetype
=
'text/plain'
)
Back
|
FazBrowse Home
|
New Git URL