Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save SuddenlyHazel/26613b42974b88dade60a9db6265fe32 to your computer and use it in GitHub Desktop.
Save SuddenlyHazel/26613b42974b88dade60a9db6265fe32 to your computer and use it in GitHub Desktop.
import Blob "mo:base/Blob";
import Debug "mo:base/Debug";
import Text "mo:base/Text";
actor {
type HeaderField = (Text, Text);
type HttpRequest = {
method: Text;
url: Text;
headers: [HeaderField];
body: Blob;
};
type HttpResponse = {
status_code: Nat16;
headers: [HeaderField];
body: Blob;
};
public query func http_request(request : HttpRequest) : async HttpResponse {
Debug.print("Woah, it works!!");
return {
status_code = 200;
headers = [("Content-Type", "text/html")];
body = Text.encodeUtf8("<b>Hello World!</b>");
};
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment