compress more images to webp
This commit is contained in:
parent
ee7245f82f
commit
fa9090cacb
54 changed files with 45 additions and 45 deletions
BIN
content/ai-system/wrap-ai-with-api/api-server-kitchen.webp
Normal file
BIN
content/ai-system/wrap-ai-with-api/api-server-kitchen.webp
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 281 KiB |
BIN
content/ai-system/wrap-ai-with-api/fastapi-browser.webp
Normal file
BIN
content/ai-system/wrap-ai-with-api/fastapi-browser.webp
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 49 KiB |
|
|
@ -11,7 +11,7 @@ In the previous two modules we've seen many industry-standard API techniques and
|
|||
> **Example:**
|
||||
> This blog site is a fully self-hosted website with basic HTTP-based APIs for handling `GET` requests from browsers. When you visit this post, your browser essentially sends a `GET` request to my server and the server responds with the HTML body for the browser to render. Knowing how to implement your own APIs enables you to do lots of cool stuff that you can control however you want!
|
||||
|
||||

|
||||

|
||||
|
||||
APIs are served by API servers—a type of application that listens to API requests sent to them and produces the corresponding responses. They are like kitchens that maintain order and delivery windows for accepting and fulfilling orders, but usually keep the process of how an order is processed behind the doors. Publicly accessible APIs that you've been playing with in previous modules are nothing magic: they are served by API servers run by providers on one or more machines identified by the APIs' corresponding domains. We will compare a few choices of Python frameworks for implementing API servers, and focus on one of them to demonstrate how to implement API fundamentals you learned from previous modules in practice.
|
||||
|
||||
|
|
@ -93,7 +93,7 @@ uvicorn main:app --reload --host 127.0.0.1 --port 8000
|
|||
|
||||
Where `main:app` points to the `app` object we implemented in the `main` program. `--reload` tells the server to automatically restart itself after we modify `main.py` for ease of development. `127.0.0.1` is the IP of "localhost"—the computer we run the server on, and `--host 127.0.0.1` means the server will only accept requests sent from the same computer. `8000` is the port our server listens on, in other words, the port used to identify our server application. You can now try to send a `GET` request to `http://127.0.0.1:8000` with another Python application and the `requests` library, or by accessing the URL in your browser, and you should be able to see the message.
|
||||
|
||||

|
||||

|
||||
|
||||
You will also be able to see the log messages from your server:
|
||||
|
||||
|
|
@ -401,7 +401,7 @@ async def classify_image(request: ImageRequest):
|
|||
|
||||
Now you have a little image classification API server! I sent it a picture of Spanish-style seafood casserole I made yesterday (it's delicious, by the way) by encoding the image to `base64` format.
|
||||
|
||||

|
||||

|
||||
|
||||
And I got the classification result from the server:
|
||||
|
||||
|
|
|
|||
BIN
content/ai-system/wrap-ai-with-api/seafood-casserole.webp
Normal file
BIN
content/ai-system/wrap-ai-with-api/seafood-casserole.webp
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 284 KiB |
Loading…
Add table
Add a link
Reference in a new issue