-
-
Save CareTiger/2f23e4b878e240b09a0a1fbfed09ccfb to your computer and use it in GitHub Desktop.
Revisions
-
raveenb revised this gist
Jun 15, 2021 . No changes.There are no files selected for viewing
-
raveenb revised this gist
Jun 15, 2021 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -40,4 +40,4 @@ nest_asyncio.apply() uvicorn.run(app, port=8000) ``` - Click on the ngrok url printed above, and visit ```/docs``` endpoint and you will have the familiar Swagger page and call your api's from there -
raveenb revised this gist
Jun 15, 2021 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -40,4 +40,4 @@ nest_asyncio.apply() uvicorn.run(app, port=8000) ``` - Click on the ngrok url printed above, and visit ```/docs``` and you will have the Swagger/OpenAPI page and call your api's from there -
raveenb revised this gist
Jun 15, 2021 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -40,4 +40,4 @@ nest_asyncio.apply() uvicorn.run(app, port=8000) ``` - Click on the ngrok url printed above, and visit /docs and you will have the Swagger/OpenAPI page and call your api's from there -
raveenb revised this gist
Jun 15, 2021 . 1 changed file with 3 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -24,9 +24,7 @@ def index(request: UserRequestIn): - Start ngrok tunnel ``` from pyngrok import ngrok ngrok_tunnel = ngrok.connect(8000) @@ -35,6 +33,9 @@ ngrok_tunnel - Patch Event Loop and start server ``` import nest_asyncio import uvicorn nest_asyncio.apply() uvicorn.run(app, port=8000) ``` -
raveenb revised this gist
Jun 15, 2021 . 1 changed file with 4 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,12 +1,15 @@ # How to Run FastAPI inside Jupyter - Ensure you have these installed and accessible from the notebook pyngrok, nest_asyncio, fastapi, uvicorn and other libs you want ``` %pip install pyngrok nest_asyncio fastapi uvicorn loguru ``` - Create a FastAPI app ``` from fastapi import FastAPI from pydantic import BaseModel from loguru import logger app = FastAPI() -
raveenb revised this gist
Jun 15, 2021 . No changes.There are no files selected for viewing
-
raveenb revised this gist
Jun 15, 2021 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,5 @@ # How to Run FastAPI inside Jupyter - Ensure you have these installed and accessible from the notebook pyngrok, nest_asyncio, fastapi, uvicorn and other libs you want ```%pip install pyngrok nest_asyncio fastapi uvicorn``` -
raveenb revised this gist
Jun 15, 2021 . 1 changed file with 20 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -15,4 +15,23 @@ class UserRequestIn(BaseModel): def index(request: UserRequestIn): logger.debug(request) return {"ok": True} ``` - Start ngrok tunnel ``` import nest_asyncio from pyngrok import ngrok import uvicorn ngrok_tunnel = ngrok.connect(8000) ngrok_tunnel ``` - Patch Event Loop and start server ``` nest_asyncio.apply() uvicorn.run(app, port=8000) ``` - Click on the ngrok url, and visit /docs and you will have the Swagger/OpenAPI page and call your api's from there -
raveenb created this gist
Jun 15, 2021 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,18 @@ - Ensure you have these installed and accessible from the notebook pyngrok, nest_asyncio, fastapi, uvicorn and other libs you want ```%pip install pyngrok nest_asyncio fastapi uvicorn``` - Create a FastAPI app ``` from fastapi import FastAPI from pydantic import BaseModel app = FastAPI() class UserRequestIn(BaseModel): text: str @app.post("/test") def index(request: UserRequestIn): logger.debug(request) return {"ok": True} ```