-
Notifications
You must be signed in to change notification settings - Fork 388
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
build_starlette_app #75
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this! It's necessary to provide a function to just get backend app instance and not start server.
Here are some preliminary comments:
pywebio/platform/fastapi.py
Outdated
@@ -151,8 +151,41 @@ def start_server(applications, port=0, host='', | |||
|
|||
.. versionadded:: 1.3 | |||
""" | |||
kwargs = locals() | |||
app = build_starlette_app(allowed_origins, applications, cdn, check_origin, debug, static_dir) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's better to use keyword arguments:
app = build_starlette_app(allowed_origins, applications, cdn, check_origin, debug, static_dir) | |
app = build_starlette_app(applications, cdn=cdn, static_dir=static_dir, debug=debug, allowed_origins=allowed_origins, check_origin=check_origin) |
pywebio/platform/fastapi.py
Outdated
uvicorn.run(app, host=host, port=port) | ||
|
||
|
||
def build_starlette_app(applications, cdn=True, static_dir=None, debug=False, allowed_origins=None, check_origin=None): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's better to use asig_app
as the function name:
def build_starlette_app(applications, cdn=True, static_dir=None, debug=False, allowed_origins=None, check_origin=None): | |
def asig_app(applications, cdn=True, static_dir=None, debug=False, allowed_origins=None, check_origin=None): |
References to build_starlette_app()
elsewhere also need to be modified accordingly
Because I plan to add wsgi_app()
or asgi_app()
to the other backend modules as well, , so it can keep the naming uniformity
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A references to build_starlette_app()
in doc was forgot to modify. Let me do it
Hello @wang0618 Oh sorry, I forgot this one indeed. |
Codecov Report
@@ Coverage Diff @@
## dev #75 +/- ##
=======================================
Coverage 87.96% 87.96%
=======================================
Files 22 22
Lines 2716 2717 +1
=======================================
+ Hits 2389 2390 +1
Misses 327 327
Continue to review full report at Codecov.
|
Thanks a lot. Didn't notice the bug before. |
Hello,
build_starlette_app
is extracted fromfastapi.start_server
in order to be used by FastAPI users who want to include a plug-and-play experience ofpywebio
into their existing FastAPI application.It provides an intermediary level between
webio_routes
(that does not handle static files) andstart_server
(that launches a uvicorn server).Indeed
start_server
is not usable for some users running FastAPI in production using both gunicorn and uvicorn (such as in https://github.com/tiangolo/uvicorn-gunicorn-fastapi-docker)