Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/juftin/fastapp
HTTP Servers Made Easy - Optimized for ML
https://github.com/juftin/fastapp
asgi fastapi machine-learning
Last synced: about 2 months ago
JSON representation
HTTP Servers Made Easy - Optimized for ML
- Host: GitHub
- URL: https://github.com/juftin/fastapp
- Owner: juftin
- License: mit
- Created: 2022-02-04T15:53:24.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2023-02-01T14:01:22.000Z (almost 2 years ago)
- Last Synced: 2024-11-15T04:59:01.939Z (about 2 months ago)
- Topics: asgi, fastapi, machine-learning
- Language: Python
- Homepage: https://juftin.com/fastapp/
- Size: 3.38 MB
- Stars: 4
- Watchers: 2
- Forks: 2
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# FastApp
HTTP Apps Made Easier with FastApp
## Installation
```shell
pip install fastapp
```## Using Out the Example Server
```shell
pip install fastapp[example]
``````shell
fastapp serve-debug fastapp.app.example:app
```## Using FastApp to build an app
Create a Python File with Endpoints, we'll call this `main.py`:
```python
from datetime import datetimefrom fastapp.app import app
@app.get("/hello")
def custom_endpoint() -> dict:
""""
This is a Custom API Endpoint
"""
return dict(timestamp=datetime.now(),
hello="world")
```Then, using the `FastApp` CLI we can serve this App:
```shell
fastapp serve-debug main:app
```...or via docker:
```shell
docker run --rm -it \
--publish 8080:8080 \
--volume ${PWD}/main.py:/root/fastapp/main.py \
juftin/fastapp:latest \
serve-debug main:app
```Test out our new endpoint:
```shell
curl \
--request GET \
--header "Content-Type: application/json" \
http://localhost:8080/hello
```Alternatively, if we want to serve this app using Gunicorn, Nginx, and the UvicornWorker we can use
the `serve` command:```shell
fastapp serve main:app
```I prefer doing this within a docker container so you don't have to run Nginx on the host machine:
```shell
docker run --rm -it \
--publish 8080:8080 \
--volume ${PWD}/main.py:/root/fastapp/main.py \
juftin/fastapp:latest \
serve main:app
```