Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
data-api-server
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
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Global Dynamic Exposure
OpenBuildingMap
data-api-server
Merge requests
!3
Switched to asynchronous quart framework
Code
Review changes
Check out branch
Download
Patches
Plain diff
Expand sidebar
Merged
Switched to asynchronous quart framework
feature/switched-to-async
into
master
Overview
2
Commits
1
Pipelines
4
Changes
6
Merged
Felix Delattre
requested to merge
feature/switched-to-async
into
master
3 years ago
Overview
2
Commits
1
Pipelines
4
Changes
6
\approve
@prehn
Edited
3 years ago
by
Felix Delattre
0
0
Merge request reports
Viewing commit
38a41f43
Show latest version
6 files
+
57
−
45
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
6
38a41f43
Switched to asynchronous quart framework
· 38a41f43
Felix Delattre
authored
3 years ago
obmdataapi/__init__.py
+
14
−
33
View file @ 38a41f43
Edit in single-file editor
Open in Web IDE
Show full file
@@ -19,45 +19,26 @@
import
logging
import
sys
from
flask
import
Flask
,
request
,
Response
from
jsonrpcserver
import
method
,
dispatch
from
quart
import
Quart
from
.jsonrpcquart
import
JSONRPCQuart
logger
=
logging
.
getLogger
()
logger
.
setLevel
(
logging
.
DEBUG
)
logger
.
addHandler
(
logging
.
StreamHandler
(
sys
.
stdout
))
logger
.
info
(
"
obmapidata has started
"
)
def
create_app
(
test_config
=
None
):
"""
Create and configure an instance of the Flask application.
"""
logger
.
info
(
"
obmapidata has started
"
)
app
=
Flask
(
__name__
,
instance_relative_config
=
True
)
app
.
config
.
from_mapping
(
# a default secret that should be overridden by instance config
SECRET_KEY
=
"
dev
"
)
if
test_config
is
None
:
# load the instance config, if it exists, when not testing
app
.
config
.
from_pyfile
(
"
config.py
"
,
silent
=
True
)
else
:
# load the test config if passed in
app
.
config
.
update
(
test_config
)
@method
def
ping
():
return
"
pong
"
@app.route
(
"
/
"
,
methods
=
[
"
POST
"
])
def
index
():
req
=
request
.
get_data
().
decode
()
response
=
dispatch
(
req
)
return
Response
(
str
(
response
),
response
.
http_status
,
mimetype
=
"
application/json
"
)
app
=
Quart
(
__name__
)
app
.
api
=
JSONRPCQuart
()
return
app
app
.
route
(
"
/
"
,
methods
=
[
"
POST
"
,
],
)(
app
.
api
.
handler
)
if
__name__
==
"
__main__
"
:
create_app
().
run
()
@app.api.add_function
async
def
ping
():
return
"
pong
"
Loading