-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
50 additions
and
1 deletion.
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,6 +1,33 @@ | ||
# Function HTTP Test Command | ||
|
||
fhttp is a command which illustrates how the func-python library | ||
fhttp is a command which illustrates how the func-python library middleware | ||
wraps a function and exposes it as a service. Useful for development. | ||
|
||
This is an example usage of the Functions HTTP middleware. | ||
|
||
To see the actual middleware which is used when building a Python Function, | ||
see the [Functions Python Scaffolding](https://github.com/knative/func/tree/main/templates/python/http) | ||
|
||
## Running | ||
|
||
Create a local virtual environment if it does not already exist: | ||
```bash | ||
python3 -m venv venv | ||
``` | ||
Activate the virtual environment: | ||
```bash | ||
source ./venv/bin/activate | ||
``` | ||
Ensure the requirements are installed: | ||
```bash | ||
pip install -r requirements.txt | ||
``` | ||
Run the application: | ||
```bash | ||
python3 ./main.py | ||
``` | ||
use `^C` to stop the application | ||
|
||
To Deactivate the virtual environment: | ||
```bash | ||
deactivate |
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,22 @@ | ||
# Functions Python Middleware | ||
|
||
An ASGI Application which will serve a Function. The ASGI application | ||
is the middleware. | ||
|
||
The middleware implements lifecycle events such as "start" and "stop", health | ||
checks for readiness and liveness, and a handler for HTTP requests. | ||
|
||
The function is expected to implement "handle", and the middleware will | ||
raise an error if the function does not implement this method. Start and stop | ||
are optional. Readiness and liveness are also optional, with the middleware | ||
providing default implementations. | ||
|
||
Signals are handled by the ASGI server implementation hypercorn and initiate | ||
shutdown of the service. | ||
|
||
## Usage | ||
|
||
To see a usage example, refer to cmd/fhttp. | ||
|
||
|
||
|