Hi - I want to expose a mojo program via a small http server. Is there a way to do this natively in mojo (i.e do the networking stdlibs exist)? If not, can I use python to do this within mojo?
a:
You can call sockets from libc.
https://github.com/crisadamo/mojo-libc
Basic socket connections
Example for server and client
Note: getaddrinfo is not working properly.
To test the socket functionality there are two functions:
test_socket_server that start listening for connections on 127.0.0.1:8083 and once a client connects it send the "Hello, Mojo!" message.
test_socket_client that connects to 127.0.0.1:8083 send the message "Hello, world Server" and prints the reply from the server.
In order to test it you need to create two notebooks, on the first one you need to run the test_socket_server() and then on the second one run test_socket_client().
Basic file system operations
Example here
To test it you can play around with the test_file function.