# Hello world!

Here is a simple sitelet that returns "Hello world!":

module Site

open WebSharper
open WebSharper.Sitelets

[<Website>]
let Main = Application.Text (fun ctx -> "Hello World!")

Hello world!
Hello world!

This sitelet has only one entry point: the root of the web application (at /, and the port is configurable). Requests to any other URL yield a 404 error. Given the root as a fixed, single endpoint and the textual response type, Application.Text is quick and easy way to create a simple, highly specialized sitelet when you need to respond with text.


# Steps

  1. Install the WebSharper project templates and create a new WebSharper minimal application:

    dotnet new websharper-min -lang f# -n MyApp

    OR

    Follow the steps in Creating a new WebSharper project from scratch. Subsequent examples will assume you have installed the WebSharper project templates, instead of going from an empty project.

  2. Run it:

    cd MyApp
    dotnet run

# Going further


# Other server responses

You can also construct a multitude of server responses, such as HTML (with or without client-side functionality), JSON data, or serving files; see sitelet responses for more information.


# Switching to larger sitelets

Unless you are planning on returning text only, Application.Text is of limited use. You will find Application.SinglePage (see the Single-page application example) and Application.MultiPage (an alias for Sitelet.Infer, see the Full-stack application example) more useful.

module Site

open WebSharper
open WebSharper.Sitelets

type EndPoint =
    | [<EndPoint "/">] Home
    | [<EndPoint "/about">] About

[<Website>]
let Main = Application.MultiPage (fun ctx -> function
    | Home ->
        Content.Page(
            [
                h1 [] [text "Hello world!"]
            ]
        )
    | About -> ...
)