This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let cts = new CancellationTokenSource() | |
let conf = { defaultConfig with cancellationToken = cts.Token } | |
let listening, server = startWebServerAsync conf (OK "Hello World") | |
Async.Start(server, cts.Token) | |
printfn "Make requests now" | |
Console.ReadKey true |> ignore | |
cts.Cancel() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(* | |
Suave.IO Tutorial #1 | |
How to setup and run on Visual Studio 2015. | |
Was confirmed as working on Visual Studio 2017. | |
Dependencies: | |
<package id="FSharp.Core" version="4.0.0.1" targetFramework="net452" /> | |
<package id="Suave" version="2.0.5" targetFramework="net452" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Settings(Enum): | |
def show(self): | |
""" | |
returns the key, value of an enum member | |
""" | |
return self.name, self.value | |
class CISettings(Settings): | |
DEBUG = False |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@unique | |
class ProductionSettings(Enum): | |
DEBUG = False | |
DB = "production" | |
DOMAIN = "foo.com" | |
def show(self): | |
""" | |
returns the key, value of an enum member |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
This will not work because it uses the @unique decorator. | |
""" | |
from enum import Enum, unique | |
@unique | |
class StagingSettings(Enum): | |
DEBUG = False | |
DB = "staging" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for setting in DevelopmentSettings: | |
print(repr(setting)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for setting in DevelopmentSettings: | |
print(setting) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
print(type(DevelopmentSettings.DEBUG)) # <enum 'DevelopmentSettings'> | |
print(isinstance(DevelopmentSettings.DEBUG, DevelopmentSettings)) # True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
print(repr(DevelopmentSettings.DEBUG)) # <DevelopmentSettings.DEBUG: True> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DevelopmentSettings.DEBUG |