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 in these scenarios by providing an API for on-the-fly compilation and an OWIN compliant server middleware for self-hosting or embedding sitelets in various compatible web servers.
Update: Note that many Warp shorthands have been integrated into WebSharper now. To use these new shorthands, you don't need Warp, but be sure to open
WebSharper.Sitelets instead. (You can find the old getting started guide that uses Warp here).
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:
Or if you use Paket:
paket init paket add nuget WebSharper.Warp
Scripting with Warp
When you add the
WebSharper.Warp NuGet package to your project in Visual Studio, a new document tab will open giving the necessary boilerplate for using Warp in scripted applications.
For instance, the SPA example above can be written as an F# script and executed in F# Interative:
#I "../packages/Owin.1.0/lib/net40" #I "../packages/Microsoft.Owin.3.0.1/lib/net45" #I "../packages/Microsoft.Owin.Host.HttpListener.3.0.1/lib/net45" #I "../packages/Microsoft.Owin.Hosting.3.0.1/lib/net45" #I "../packages/Microsoft.Owin.FileSystems.3.0.1/lib/net45" #I "../packages/Microsoft.Owin.StaticFiles.3.0.1/lib/net45" #I "../packages/WebSharper.220.127.116.11/lib/net40" #I "../packages/WebSharper.Compiler.18.104.22.168/lib/net40" #I "../packages/WebSharper.Owin.22.214.171.124/lib/net45" #load "../packages/WebSharper.Warp.126.96.36.199/tools/reference.fsx" open WebSharper open WebSharper.Html.Server let MySite = Warp.CreateSPA (fun ctx -> [H1 [Text "Hello world!"]]) do Warp.RunAndWaitForInput(MySite) |> ignore
If you use Paket, then you should replace the
#-lines above with this one:
In FSI, you should see:
--> Added 'c:\sandbox\test\Library1\HelloWorld\../packages/Owin.1.0/lib/net40' to library include path [... more lines ...] [Loading c:\sandbox\test\Library1\packages\WebSharper.Warp.188.8.131.52\tools\reference.fsx] namespace FSI_0004 Serving http://localhost:9000/, press Enter to stop.
You can then test this application as before: