Search code examples
ubuntusuave

Suave Web Application running on Ubuntu


I'm looking for a simple 'Hello, World" example of Suave running on Ubuntu. I have tried looking all over the net to no avail


Solution

  • I have managed to get it up and running on Xubuntu 16.04. I am using dotnet core and visual studio code.

    To the best of my memory :) :

    Install dot net core (from https://www.microsoft.com/net/core#ubuntu)

    sudo sh -c 'echo "deb [arch=amd64] https://apt-mo.trafficmanager.net/repos/dotnet/ xenial main" > /etc/apt/sources.list.d/dotnetdev.list'
    
    sudo apt-key adv --keyserver apt-mo.trafficmanager.net --recv-keys 417A0893
    
    sudo apt-get update
    
    sudo apt-get install dotnet-dev-1.0.0-preview2-003121
    

    Then install visual studio code: https://code.visualstudio.com/Docs/?dv=linux64_deb

    Add ionide extension for syntax highlight etc. In VS Code Ctrl + P - ext install ionide-fsharp

    Then in terminal (will create a blank Fsharp project):

    mkdir hwapp
    
    cd hwapp
    
    dotnet new --lang f#
    

    Then add suave to project.json file:

    "dependencies": {
    
        "Microsoft.FSharp.Core.netcore": "1.0.0-alpha-160509",
    
        "Suave": "2.0.0-alpha4",
    
        "Microsoft.NETCore.App": {
    
      "type": "platform",
    
      "version": "1.0.0"
    
    }
    

    Then the standard suave helloworld should work in Program.fs

    open Suave
    
    startWebServer defaultConfig (Successful.OK "Hello World!")