Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Roadmap
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
Model registry
Operate
Environments
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
Robert Goldmann
Roadmap
Commits
4fd04cac
Commit
4fd04cac
authored
5 years ago
by
Robert Goldmann
Browse files
Options
Downloads
Patches
Plain Diff
api: use TheCodeLabs util packages
parent
339cca02
No related branches found
No related tags found
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
api/Constants.py
+1
-0
1 addition, 0 deletions
api/Constants.py
api/Pipfile
+7
-0
7 additions, 0 deletions
api/Pipfile
api/Pipfile.lock
+23
-4
23 additions, 4 deletions
api/Pipfile.lock
api/RoadmapAPIServer.py
+38
-53
38 additions, 53 deletions
api/RoadmapAPIServer.py
with
69 additions
and
57 deletions
api/Constants.py
0 → 100644
+
1
−
0
View file @
4fd04cac
APP_NAME
=
'
RoadmapApi
'
This diff is collapsed.
Click to expand it.
api/Pipfile
+
7
−
0
View file @
4fd04cac
...
...
@@ -3,6 +3,11 @@ url = "https://pypi.python.org/simple"
verify_ssl
=
true
name
=
"pypi"
[[source]]
url
=
"https://pypi.thecodedev.de"
verify_ssl
=
true
name
=
"TheCodeLabs"
[requires]
python_version
=
"3.7"
...
...
@@ -11,6 +16,8 @@ flask = "==1.1.2"
flask_jwt_extended = "
=
=
3.24
.
1
"
gevent = "
=
=
1.5
.
0
"
psycopg2 = "
=
=
2.8
.
5
"
TheCodeLabs-BaseUtils = "
=
=
1.0
.
0
"
TheCodeLabs-FlaskUtils = "
=
=
1.0
.
2
"
[dev-packages]
pyyaml = "
=
=
5.3
.
1
"
This diff is collapsed.
Click to expand it.
api/Pipfile.lock
+
23
−
4
View file @
4fd04cac
{
"_meta"
:
{
"hash"
:
{
"sha256"
:
"
1aaa3c81cbaa411a612d61507c5ee3b1093c021977a99472b39661b380700170
"
"sha256"
:
"
8217206c84c7464d990a1d9955f2a7d271997ed4a052584a0f63c3d387d0359f
"
},
"pipfile-spec"
:
6
,
"requires"
:
{
...
...
@@ -12,6 +12,11 @@
"name"
:
"pypi"
,
"url"
:
"https://pypi.python.org/simple"
,
"verify_ssl"
:
true
},
{
"name"
:
"TheCodeLabs"
,
"url"
:
"https://pypi.thecodedev.de"
,
"verify_ssl"
:
true
}
]
},
...
...
@@ -52,10 +57,10 @@
},
"click"
:
{
"hashes"
:
[
"sha256:
8a18b4ea89d8820c5d0c7da8a64b2c324b4dabb695804dbfea19b9be9d88c0cc
"
,
"sha256:
e345d143d80bf5ee7534056164e5e112ea5e22716bbb1ce727941f4c8b471b9a
"
"sha256:
d2b5255c7c6349bc1bd1e59e08cd12acbbd63ce649f2588755783aa94dfb6b1a
"
,
"sha256:
dacca89f4bfadd5de3d7489b7c8a566eee0d3676333fbb50030263894c38c0dc
"
],
"version"
:
"==7.1.
1
"
"version"
:
"==7.1.
2
"
},
"flask"
:
{
"hashes"
:
[
...
...
@@ -221,6 +226,20 @@
],
"version"
:
"==1.14.0"
},
"thecodelabs-baseutils"
:
{
"hashes"
:
[
"sha256:daab1cf2480b3c1352ef94f78774d4c4c8759d91a6c50b113bcb1c73081263cb"
],
"index"
:
"pypi"
,
"version"
:
"==1.0.0"
},
"thecodelabs-flaskutils"
:
{
"hashes"
:
[
"sha256:98833b87fd1b0b42a7ad6ac9de3b79676623cc21b0fabc940863412e8ee40961"
],
"index"
:
"pypi"
,
"version"
:
"==1.0.2"
},
"werkzeug"
:
{
"hashes"
:
[
"sha256:2de2a5db0baeae7b2d2664949077c2ac63fbd16d98da0ff71837f7d1dea3fd43"
,
...
...
This diff is collapsed.
Click to expand it.
api/RoadmapAPIServer.py
+
38
−
53
View file @
4fd04cac
import
datetime
import
json
import
logging
import
os
from
flask
import
Flask
,
send_from_directory
,
request
from
TheCodeLabs_BaseUtils
import
DefaultLogger
from
TheCodeLabs_FlaskUtils
import
FlaskBaseApp
from
flask
import
jsonify
from
flask
import
send_from_directory
,
request
from
flask_jwt_extended
import
(
JWTManager
,
create_access_token
)
from
gevent.pywsgi
import
WSGIServer
import
Constants
from
Database
import
Database
from
RequestValidator
import
RequestValidator
,
ValidationError
from
UserService
import
UserService
from
blueprints
import
SubTaskAPI
,
MilestoneAPI
,
TaskAPI
,
RoadmapAPI
with
open
(
'
version.json
'
,
'
r
'
)
as
f
:
VERSION
=
json
.
load
(
f
)
VERSION
=
VERSION
[
'
version
'
]
LOGGER
=
DefaultLogger
().
create_logger_if_not_exists
(
Constants
.
APP_NAME
)
with
open
(
"
settings.json
"
,
"
r
"
)
as
f
:
SETTINGS
=
json
.
load
(
f
)
SERVER_SETTINGS
=
SETTINGS
[
"
server
"
]
app
=
Flask
(
__name__
)
class
RoadmapApi
(
FlaskBaseApp
):
def
__init__
(
self
,
appName
:
str
,
rootDir
:
str
,
logger
:
logging
.
Logger
,
settingsPath
:
str
):
super
().
__init__
(
appName
,
rootDir
,
logger
,
settingsPath
=
settingsPath
)
self
.
_database
=
Database
(
self
.
_settings
[
"
database
"
])
self
.
_userService
=
UserService
(
self
.
_settings
[
"
users
"
])
app
.
config
[
"
JWT_SECRET_KEY
"
]
=
SERVER_SETTINGS
[
"
secret
"
]
def
_register_blueprints
(
self
,
app
):
app
.
config
[
"
JWT_SECRET_KEY
"
]
=
self
.
_serverSettings
[
"
secret
"
]
jwt
=
JWTManager
(
app
)
database
=
Database
(
SETTINGS
[
"
database
"
])
userService
=
UserService
(
SETTINGS
[
"
users
"
])
@app.route
(
'
/
'
)
def
index
():
return
send_from_directory
(
"
docs
"
,
"
api.html
"
)
@app.route
(
'
/version
'
,
methods
=
[
'
GET
'
])
def
version
():
return
jsonify
(
VERSION
)
@app.route
(
'
/login
'
,
methods
=
[
'
POST
'
])
def
login
():
try
:
...
...
@@ -47,7 +40,7 @@ def login():
except
ValidationError
as
e
:
return
e
.
response
,
400
password
=
userService
.
get_password_by_username
(
parameters
[
"
username
"
])
password
=
self
.
_
userService
.
get_password_by_username
(
parameters
[
"
username
"
])
if
password
is
None
:
return
jsonify
({
"
success
"
:
False
,
"
msg
"
:
"
Unknown username
"
}),
401
...
...
@@ -58,20 +51,12 @@ def login():
access_token
=
create_access_token
(
identity
=
parameters
[
"
username
"
],
expires_delta
=
expires
)
return
jsonify
(
access_token
=
access_token
),
200
app
.
register_blueprint
(
RoadmapAPI
.
construct_blueprint
(
database
))
app
.
register_blueprint
(
MilestoneAPI
.
construct_blueprint
(
database
))
app
.
register_blueprint
(
TaskAPI
.
construct_blueprint
(
database
))
app
.
register_blueprint
(
SubTaskAPI
.
construct_blueprint
(
database
))
app
.
register_blueprint
(
RoadmapAPI
.
construct_blueprint
(
self
.
_database
))
app
.
register_blueprint
(
MilestoneAPI
.
construct_blueprint
(
self
.
_database
))
app
.
register_blueprint
(
TaskAPI
.
construct_blueprint
(
self
.
_database
))
app
.
register_blueprint
(
SubTaskAPI
.
construct_blueprint
(
self
.
_database
))
if
__name__
==
"
__main__
"
:
if
SERVER_SETTINGS
[
"
useSSL
"
]:
http_server
=
WSGIServer
((
SERVER_SETTINGS
[
"
listen
"
],
SERVER_SETTINGS
[
"
port
"
]),
app
,
keyfile
=
SERVER_SETTINGS
[
"
keyfile
"
],
certfile
=
SERVER_SETTINGS
[
"
certfile
"
])
else
:
http_server
=
WSGIServer
((
SERVER_SETTINGS
[
"
listen
"
],
SERVER_SETTINGS
[
"
port
"
]),
app
)
print
(
'
RoadmapClient {}({}) - Listening on {}:{}...
'
.
format
(
VERSION
[
'
name
'
],
VERSION
[
'
code
'
],
SERVER_SETTINGS
[
'
listen
'
],
SERVER_SETTINGS
[
'
port
'
]))
http_server
.
serve_forever
()
roadmapApi
=
RoadmapApi
(
Constants
.
APP_NAME
,
os
.
path
.
dirname
(
__file__
),
LOGGER
,
'
settings.json
'
)
roadmapApi
.
start_server
()
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