Skip to content

TCP Service framework for the mojo programming language 🔥

License

Notifications You must be signed in to change notification settings

Jensen-holm/FireTCP

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FireTCP

Bring your 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.

Example code

app.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

from FireTCP import TCP


fn 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"

About

TCP Service framework for the mojo programming language 🔥

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published