-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: allow running review app to validate PR from external contribution
* create a review app to access to different basic streamsync application
- Loading branch information
1 parent
5242575
commit 7ff972b
Showing
5 changed files
with
150 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
web: streamsync --port $PORT --host 0.0.0.0 --enable-remote-edit edit apps/hello | ||
web: python apps/reviewapp.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import os | ||
|
||
import uvicorn | ||
import streamsync.serve | ||
from fastapi import FastAPI, Response | ||
|
||
def app_path(app_name: str) -> str: | ||
return os.path.join(os.path.dirname(__file__), app_name) | ||
|
||
root_asgi_app = FastAPI(lifespan=streamsync.serve.lifespan) | ||
sub_asgi_app_1 = streamsync.serve.get_asgi_app(app_path("hello"), "edit", enable_remote_edit=True) | ||
sub_asgi_app_2 = streamsync.serve.get_asgi_app(app_path("default"), "edit", enable_remote_edit=True) | ||
sub_asgi_app_3 = streamsync.serve.get_asgi_app(app_path("quickstart"), "edit", enable_remote_edit=True) | ||
|
||
root_asgi_app.mount("/hello/", sub_asgi_app_1) | ||
root_asgi_app.mount("/default/", sub_asgi_app_2) | ||
root_asgi_app.mount("/quickstart/", sub_asgi_app_3) | ||
|
||
|
||
|
||
@root_asgi_app.get("/") | ||
async def init(): | ||
links = [ | ||
f'<li><a href="/hello">hello</a></li>', | ||
f'<li><a href="/default"">default</a></li>', | ||
f'<li><a href="/quickstart">quickstart</a></li>', | ||
] | ||
|
||
return Response(""" | ||
<h1>Streamsync review app</h1> | ||
<ul> | ||
""" + "\n".join(links) + """ | ||
</ul> | ||
""") | ||
|
||
uvicorn.run(root_asgi_app, | ||
host="0.0.0.0", | ||
port=os.getenv('PORT', 8000), | ||
log_level="warning", | ||
ws_max_size=streamsync.serve.MAX_WEBSOCKET_MESSAGE_SIZE) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters