Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
Matrix Webhook
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
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
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
Guilhem Saurel
Matrix Webhook
Commits
781e4fd7
Commit
781e4fd7
authored
6 years ago
by
Guilhem Saurel
Browse files
Options
Downloads
Patches
Plain Diff
basic http server
parent
bfc7a130
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
main.py
+35
-0
35 additions, 0 deletions
main.py
with
35 additions
and
0 deletions
main.py
0 → 100755
+
35
−
0
View file @
781e4fd7
#!/usr/bin/env python
"""
wifi-with-matrix script.
Bridge between https://code.ffdn.org/FFDN/wifi-with-me & a matrix room
"""
from
http.server
import
BaseHTTPRequestHandler
,
HTTPServer
SERVER_ADDRESS
=
(
''
,
4785
)
class
Forwarder
(
BaseHTTPRequestHandler
):
"""
Class given to the server, st. it knows what to do with a request.
This one handles the HTTP request, and forwards it to the matrix room.
"""
def
do_POST
(
self
):
"""
main method, get a json dict from wifi-with-me, send a message to a matrix room
"""
self
.
ret_ok
()
def
ret_ok
(
self
):
"""
return a success status
"""
self
.
send_response
(
200
)
self
.
send_header
(
'
Content-Type
'
,
'
application/json
'
)
self
.
end_headers
()
self
.
wfile
.
write
(
b
"
{
'
status
'
:
'
OK
'
}
"
)
if
__name__
==
'
__main__
'
:
HTTPServer
(
SERVER_ADDRESS
,
Forwarder
).
serve_forever
()
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