<commit_before># websharper.warp

[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/intellifactory/websharper.warp?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)

WebSharper Warp is a friction-less web development library for building scripted and standalone **full-stack** F# client-server applications. Warp is built on top of WebSharper and is designed to help you become more productive and benefit from the rich WebSharper features more quickly and more directly.  While Warp shorthands target the most typical applications (text, SPAs, multi-page) and easy exploration, you can extend your Warp applications with the full WebSharper capabilities at any time.

# Installing

To get started with Warp is super-easy, all you need is to open a new F# Console Application (or any other F# project type if you want to script applications), and add `WebSharper.Warp` to it:

```
Install-Package WebSharper.Warp
```

# Hello world!

The simplest Warp site just serves text and consist of a single endpoint (`/`), by default listening on `http://localhost:9000`.

```fsharp
open WebSharper

let MyApp = Warp.Text "Hello world!"

[<EntryPoint>]
do Warp.RunAndWaitForInput(MyApp) |> ignore
```

![](http://i.imgur.com/fZgqeKjl.png)

# Single Page Applications

While serving text is fun and often useful, going beyond isn't any complicated. Warp also helps constructing HTML.  In the most basic form, you can create single page applications (SPAs) using `Warp.CreateSPA` and WebSharper's server-side HTML combinators:

```fsharp
open WebSharper.Html.Server

let MySite =
    Warp.CreateSPA (fun ctx ->
        [H1 [Text "Hello world!"]])

[<EntryPoint>]
do Warp.RunAndWaitForInput(MySite) |> ignore
```

![](http://i.imgur.com/xYITvCql.png)

# Multi-page applications

Using multiple `EndPoints` and `Warp.CreateApplication`, you can define multi-page Warp applications.  When constructing the actual pages, `Warp.Page` comes handy - allowing you to fill the `Title`, `Head`, and the `Body` parts on demand.  `Warp.Page` pages are fully autonomous and will **automatically contain the dependencies of any client-side code used on the page**.

```fsharp
type Endpoints =
    | [<EndPoint "GET /">] Home
    | [<EndPoint "GET /about">] About

let MySite =
    Warp.CreateApplication (fun ctx endpoint ->
        let (=>) label endpoint = A [HRef (ctx.Link endpoint)] -< [Text label]
        match endpoint with
        | Endpoints.Home ->
            Warp.Page(
                Body =
                    [
                        H1 [Text "Hello world!"]
                        "About" => Endpoint.About
                    ]
            )
        | Endpoints.About ->
            Warp.Page(
                Body =
                    [
                        P [Text "This is a simple app"]
                        "Home" => Endpoint.Home
                    ]
            )<commit_msg>Endpoint -> Endpoints in readme?<commit_after># websharper.warp

[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/intellifactory/websharper.warp?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)

WebSharper Warp is a friction-less web development library for building scripted and standalone **full-stack** F# client-server applications. Warp is built on top of WebSharper and is designed to help you become more productive and benefit from the rich WebSharper features more quickly and more directly.  While Warp shorthands target the most typical applications (text, SPAs, multi-page) and easy exploration, you can extend your Warp applications with the full WebSharper capabilities at any time.

# Installing

To get started with Warp is super-easy, all you need is to open a new F# Console Application (or any other F# project type if you want to script applications), and add `WebSharper.Warp` to it:

```
Install-Package WebSharper.Warp
```

# Hello world!

The simplest Warp site just serves text and consist of a single endpoint (`/`), by default listening on `http://localhost:9000`.

```fsharp
open WebSharper

let MyApp = Warp.Text "Hello world!"

[<EntryPoint>]
do Warp.RunAndWaitForInput(MyApp) |> ignore
```

![](http://i.imgur.com/fZgqeKjl.png)

# Single Page Applications

While serving text is fun and often useful, going beyond isn't any complicated. Warp also helps constructing HTML.  In the most basic form, you can create single page applications (SPAs) using `Warp.CreateSPA` and WebSharper's server-side HTML combinators:

```fsharp
open WebSharper.Html.Server

let MySite =
    Warp.CreateSPA (fun ctx ->
        [H1 [Text "Hello world!"]])

[<EntryPoint>]
do Warp.RunAndWaitForInput(MySite) |> ignore
```

![](http://i.imgur.com/xYITvCql.png)

# Multi-page applications

Using multiple `EndPoints` and `Warp.CreateApplication`, you can define multi-page Warp applications.  When constructing the actual pages, `Warp.Page` comes handy - allowing you to fill the `Title`, `Head`, and the `Body` parts on demand.  `Warp.Page` pages are fully autonomous and will **automatically contain the dependencies of any client-side code used on the page**.

```fsharp
type Endpoints =
    | [<EndPoint "GET /">] Home
    | [<EndPoint "GET /about">] About

let MySite =
    Warp.CreateApplication (fun ctx endpoint ->
        let (=>) label endpoint = A [HRef (ctx.Link endpoint)] -< [Text label]
        match endpoint with
        | Endpoints.Home ->
            Warp.Page(
                Body =
                    [
                        H1 [Text "Hello world!"]
                        "About" => Endpoints.About
                    ]
            )
        | Endpoints.About ->
            Warp.Page(
                Body =
                    [
                        P [Text "This is a simple app"]
                        "Home" => Endpoints.Home
                    ]
            )
{'fraction_non_alphanumeric': 0.09869203329369798, 'fraction_numerical': 0.0027178528962119924, 'mean_word_length': 2.878787878787879, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 30, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6899867', 'n_tokens_mistral': 1770, 'n_tokens_neox': 1680, 'n_words': 615}