Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/Jensen-holm/FireTCP
TCP Service framework for the mojo programming language 🔥
https://github.com/Jensen-holm/FireTCP
mojo rest-api tcp-client tcp-client-server tcp-server websocket
Last synced: 8 days ago
JSON representation
TCP Service framework for the mojo programming language 🔥
- Host: GitHub
- URL: https://github.com/Jensen-holm/FireTCP
- Owner: Jensen-holm
- License: mit
- Created: 2023-11-21T21:40:34.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-07-30T19:55:51.000Z (6 months ago)
- Last Synced: 2024-07-31T02:10:37.342Z (6 months ago)
- Topics: mojo, rest-api, tcp-client, tcp-client-server, tcp-server, websocket
- Language: Mojo
- Homepage:
- Size: 19.2 MB
- Stars: 16
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-mojo-max-mlir - Jensen-holm/FireTCP - holm/FireTCP?style=social"/> : TCP Service framework for the mojo programming language 🔥 (TCP Framework)
- awesome-mojo-max-mlir - Jensen-holm/FireTCP - holm/FireTCP?style=social"/> : TCP Service framework for the mojo programming language 🔥 (TCP Framework)
README
# FireTCP
Bring your [mojo](https://www.modular.com/max/mojo) Api to your network with a simple FireTCP server!!
### Dependencies
- mojo version 24.4.0 or newer
- Python version 3.10 or newer### Hello FireApi
Step 1: `$ mkdir hello_fire_api && cd hello_fire_api`Step 2: `$ curl -sS https://raw.githubusercontent.com/Jensen-holm/FireTCP/main/install.sh | bash`
Step 3: Once you have made a project and cloned the FireApi you can get coding! Check out the examples below or in the examples directory before getting started or [read this tutorial I made on medium](https://medium.com/@jensen.dev.01/socket-programming-in-mojo-e113f6c8cbef).
### Example code
app.mojo
```mojo
from FireTCP import TCP@value
struct HelloService(TCP.Service):
fn func(self, req: TCP.Request) raises -> TCP.Response:
return TCP.Response(
body="You sent the following data: " + req.body(),
)fn main() raises -> None:
var server = TCP.TCPLite[HelloService](
service=HelloService(),
port=9090,
host_addr="127.0.0.1",
)server.serve()
```client.mojo
```mojo
from FireTCP import TCPfn main() raises -> None:
var client = TCP.Client(
port=9090,
host_name="127.0.0.1",
)var request = TCP.Request(
body="Hello FireTCP",
)var response = client.send_request(request)
print(response.body())
```output: "You sent the following data: Hello FireTCP"