Skip to content

Commit

Permalink
Fixed test mode
Browse files Browse the repository at this point in the history
  • Loading branch information
Cutwell committed Aug 7, 2023
1 parent 34667eb commit 8727c2e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
5 changes: 4 additions & 1 deletion python-web-io/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,7 @@ openai = "^0.27.8"

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
build-backend = "poetry.core.masonry.api"

[tool.poetry.scripts]
python_web_io = "python_web_io.main:test_mode"
10 changes: 7 additions & 3 deletions python-web-io/python_web_io/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ async def lifespan(app: FastAPI):
"icon": "🎯",
"css": [
"https://unpkg.com/[email protected]/normalize.css",
"https://cdn.jsdelivr.net/npm/water.css@2/out/water.css"
"https://cdn.jsdelivr.net/npm/water.css@2/out/water.css",
],
}

Expand Down Expand Up @@ -306,7 +306,8 @@ async def http_exception_handler(request: Request, exc: HTTPException):
)


if __name__ == "__main__":
# test mode
def test_mode():
"""
If running python_web_io/main.py directly (instead of via uvicorn with an entrypoint), accept CLI arguments.
Ideal for quickly testing capabilities without creating `.envrc` or `.pythonwebio/config.toml` files.
Expand All @@ -321,7 +322,6 @@ def parse_command_line_arguments():
parser.add_argument(
"--script",
type=str,
default="default_value1",
help="Set the python script (override `config.toml` settings) (format: e.g.:`path/to/file.py:main`).",
)
parser.add_argument(
Expand All @@ -344,3 +344,7 @@ def parse_command_line_arguments():
app.state.config_path = args.config

uvicorn.run(app, host=args.host, port=args.port)


if __name__ == "__main__":
test_mode()

0 comments on commit 8727c2e

Please sign in to comment.