Pyre is a set of components for building networking systems in Mojo.
Pyre currently has the following components:
- Service trait that takes in a
Request
and returns aResponse
Learn how to get up and running with Mojo on the Modular website. Once you have a Mojo project set up locally,
- Add the
mojo-community
channel to yourmojoproject.toml
, e.g:[project] channels = ["conda-forge", "https://conda.modular.com/max", "https://repo.prefix.dev/mojo-community"]
- Add
pyre
in dependencies:[dependencies] pyre = ">=0.1.0"
- Run
magic install
at the root of your project, wheremojoproject.toml
is located - Pyre should now be installed. You can import all the default imports at once, e.g:
or import individual structs and functions, e.g.
from pyre import *
from pyre.service import Service
- To use the
Service
trait:E.g implement atrait Service: fn func(self, req: Request) raises -> Response: ...
Printer
service that prints some details about the request to console:from pyre import Request, Response, OK @always_inline fn printer(req: Request) -> Response: print("Got a request on ", req.uri.path, " with method ", req.method) return OK(req.body_raw)
Want your name to show up here? See CONTRIBUTING.md!
Made with contrib.rocks.