Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
CI
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
4
Issues
4
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
azubi 2019
CI
Commits
bcd0c2a8
Commit
bcd0c2a8
authored
Aug 09, 2020
by
Fabian Wandt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Suche von Usern über username anstatt uid
parent
a39c19ec
Pipeline
#24008
failed with stages
Changes
5
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
13 additions
and
11 deletions
+13
-11
gitlab_api/app/__pycache__/app.cpython-37.pyc
gitlab_api/app/__pycache__/app.cpython-37.pyc
+0
-0
gitlab_api/app/__pycache__/db_model.cpython-37.pyc
gitlab_api/app/__pycache__/db_model.cpython-37.pyc
+0
-0
gitlab_api/app/api.py
gitlab_api/app/api.py
+11
-9
gitlab_api/app/api_test.py
gitlab_api/app/api_test.py
+2
-2
gitlab_api/app/db.sqlite
gitlab_api/app/db.sqlite
+0
-0
No files found.
gitlab_api/app/__pycache__/app.cpython-37.pyc
View file @
bcd0c2a8
No preview for this file type
gitlab_api/app/__pycache__/db_model.cpython-37.pyc
View file @
bcd0c2a8
No preview for this file type
gitlab_api/app/api.py
View file @
bcd0c2a8
...
...
@@ -7,6 +7,8 @@ import os
#User erstellen
@
app
.
route
(
'/user'
,
methods
=
[
'POST'
])
def
add_user
():
...
...
@@ -30,15 +32,15 @@ def get_users():
return
jsonify
(
result
)
#Ausgabe eines einzelnen Users
@
app
.
route
(
'/user/<
id
>'
,
methods
=
[
'GET'
])
def
get_user
(
id
):
user
=
User
.
query
.
get
(
id
)
@
app
.
route
(
'/user/<
username
>'
,
methods
=
[
'GET'
])
def
get_user
(
username
):
user
=
User
.
query
.
filter_by
(
username
=
username
).
first
(
)
return
user_schema
.
jsonify
(
user
)
#Bearbeiten eines Users
@
app
.
route
(
'/user/<
id
>'
,
methods
=
[
'PUT'
])
def
update_user
(
id
):
user
=
User
.
query
.
get
(
id
)
@
app
.
route
(
'/user/<
username
>'
,
methods
=
[
'PUT'
])
def
update_user
(
username
):
user
=
User
.
query
.
filter_by
(
username
=
username
).
first
(
)
vname
=
request
.
json
[
'vname'
]
nname
=
request
.
json
[
'nname'
]
...
...
@@ -55,9 +57,9 @@ def update_user(id):
return
user_schema
.
jsonify
(
user
)
#Löschen eines Users
@
app
.
route
(
'/user/<
id
>'
,
methods
=
[
'DELETE'
])
def
delete_user
(
id
):
user
=
User
.
query
.
get
(
id
)
@
app
.
route
(
'/user/<
username
>'
,
methods
=
[
'DELETE'
])
def
delete_user
(
username
):
user
=
User
.
query
.
filter_by
(
username
=
username
).
first
(
)
db
.
session
.
delete
(
user
)
db
.
session
.
commit
()
...
...
gitlab_api/app/api_test.py
View file @
bcd0c2a8
...
...
@@ -25,7 +25,7 @@ def post():
#Delete Request: User Delete
def
delete
():
print
(
"DELETE"
)
url
=
"http://0.0.0.0:5000/user/
1
"
url
=
"http://0.0.0.0:5000/user/
kmueller
"
r
=
requests
.
delete
(
url
)
print
(
r
.
status_code
)
print
(
r
.
content
)
...
...
@@ -33,7 +33,7 @@ def delete():
#Put Request: User Update
def
put
():
print
(
"PUT"
)
url
=
"http://0.0.0.0:5000/user/
1
"
url
=
"http://0.0.0.0:5000/user/
hpotter
"
data
=
{
'vname'
:
'kevin'
,
'nname'
:
'mueller'
,
'username'
:
'kmueller'
,
'aktiv'
:
'nein'
}
header
=
{
'Content-type'
:
'application/json'
}
r
=
requests
.
put
(
url
,
data
=
json
.
dumps
(
data
),
headers
=
header
)
...
...
gitlab_api/app/db.sqlite
View file @
bcd0c2a8
No preview for this file type
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment