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
2a259454
Commit
2a259454
authored
3 years ago
by
Jeremy Whiting
Browse files
Options
Downloads
Patches
Plain Diff
Implement basic get requests.
Skeletons for login-name, properties.json and query commands.
parent
470297c3
Branches
Branches containing commit
Tags
Tags containing commit
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
+34
-3
34 additions, 3 deletions
src/steamos-devkit-service.py
with
34 additions
and
3 deletions
src/steamos-devkit-service.py
+
34
−
3
View file @
2a259454
...
...
@@ -24,19 +24,50 @@
#SOFTWARE.
from
http.server
import
BaseHTTPRequestHandler
import
json
import
socketserver
import
urllib.parse
SERVICE_PORT
=
32000
# root until config is loaded and told otherwise, etc.
entry_point_user
=
"
root
"
properties
=
{
"
key
"
:
"
value
"
}
class
DevkitHandler
(
BaseHTTPRequestHandler
):
def
_send_headers
(
self
,
code
):
def
_send_headers
(
self
,
code
,
type
):
self
.
send_response
(
code
)
self
.
send_header
(
"
Content-type
"
,
"
text/html
"
)
self
.
send_header
(
"
Content-type
"
,
type
)
self
.
end_headers
()
def
do_GET
(
self
):
print
(
"
GET request to path {} from {}
"
.
format
(
self
.
path
,
self
.
client_address
[
0
]))
self
.
_send_headers
(
200
)
if
(
self
.
path
==
"
/login-name
"
):
self
.
_send_headers
(
200
,
"
text/plain
"
)
self
.
wfile
.
write
(
entry_point_user
.
encode
())
return
elif
(
self
.
path
==
"
/properties.json
"
):
self
.
_send_headers
(
200
,
"
application/json
"
)
self
.
wfile
.
write
(
json
.
dumps
(
properties
).
encode
())
return
else
:
query
=
urllib
.
parse
.
parse_qs
(
self
.
path
[
2
:])
print
(
"
query is {}
"
.
format
(
query
))
if
(
len
(
query
)
>
0
and
query
[
"
command
"
]):
command
=
query
[
"
command
"
][
0
]
if
(
command
==
"
ping
"
):
self
.
_send_headers
(
200
,
"
text/plain
"
)
self
.
wfile
.
write
(
"
pong
\n
"
.
encode
())
return
else
:
self
.
_send_headers
(
404
,
""
)
return
self
.
_send_headers
(
200
,
"
text/html
"
)
self
.
wfile
.
write
(
"
Get works
\n
"
.
encode
())
def
do_POST
(
self
):
...
...
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