Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
SteamOS Devkit Service
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
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
devkit
SteamOS Devkit Service
Commits
470297c3
Commit
470297c3
authored
3 years ago
by
Jeremy Whiting
Browse files
Options
Downloads
Patches
Plain Diff
Service runs and accepts http GET, POST requests, etc.
parent
e0283b1f
No related branches found
No related tags found
1 merge request
!1
Rewrite devkit service in python.
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/steamos-devkit-service.py
+70
-0
70 additions, 0 deletions
src/steamos-devkit-service.py
with
70 additions
and
0 deletions
src/steamos-devkit-service.py
0 → 100644
+
70
−
0
View file @
470297c3
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#MIT License
#
#Copyright (c) 2022 Valve Software inc., Collabora Ltd
#
#Permission is hereby granted, free of charge, to any person obtaining a copy
#of this software and associated documentation files (the "Software"), to deal
#in the Software without restriction, including without limitation the rights
#to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
#copies of the Software, and to permit persons to whom the Software is
#furnished to do so, subject to the following conditions:
#
#The above copyright notice and this permission notice shall be included in all
#copies or substantial portions of the Software.
#
#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
#IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
#FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
#AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
#LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
#OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
#SOFTWARE.
from
http.server
import
BaseHTTPRequestHandler
import
socketserver
SERVICE_PORT
=
32000
class
DevkitHandler
(
BaseHTTPRequestHandler
):
def
_send_headers
(
self
,
code
):
self
.
send_response
(
code
)
self
.
send_header
(
"
Content-type
"
,
"
text/html
"
)
self
.
end_headers
()
def
do_GET
(
self
):
print
(
"
GET request to path {} from {}
"
.
format
(
self
.
path
,
self
.
client_address
[
0
]))
self
.
_send_headers
(
200
)
self
.
wfile
.
write
(
"
Get works
\n
"
.
encode
())
def
do_POST
(
self
):
if
(
self
.
path
==
"
/register
"
):
print
(
"
register request from {}
"
.
format
(
self
.
client_address
[
0
]))
self
.
_send_headers
(
200
)
self
.
wfile
.
write
(
"
Registered
\n
"
.
encode
())
class
DevkitService
:
def
__init__
(
self
):
# TODO: Get from config if set
self
.
port
=
SERVICE_PORT
self
.
httpd
=
socketserver
.
TCPServer
((
""
,
self
.
port
),
DevkitHandler
,
bind_and_activate
=
False
)
print
(
"
serving at port: {}
"
.
format
(
self
.
port
))
self
.
httpd
.
allow_reuse_address
=
True
self
.
httpd
.
server_bind
()
self
.
httpd
.
server_activate
()
try
:
self
.
httpd
.
serve_forever
()
except
KeyboardInterrupt
:
pass
self
.
httpd
.
server_close
()
print
(
"
done serving at port: {}
"
.
format
(
self
.
port
))
if
__name__
==
"
__main__
"
:
service
=
DevkitService
()
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