-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStart-PodeServer.ps1
75 lines (66 loc) · 2.53 KB
/
Start-PodeServer.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
Import-Module Pode.Web
Start-PodeServer {
# Enable Loggin to Terminal
#New-PodeLoggingMethod -Path .\logs -Name "PodeWebServer.log" | Enable-PodeErrorLogging
New-PodeLoggingMethod -Terminal | Enable-PodeErrorLogging
# Use default system Theme
Use-PodeWebTemplates -Title "Tinu's PodeWebApp" -Theme Auto
# Add Navbar
$Properties = @{
Name = 'Pode.Web on GitHub'
Url = 'https://github.com/Badgerati/Pode.Web'
Icon = 'help-circle'
}
$navgithub = New-PodeWebNavLink @Properties -NewTab
Set-PodeWebNavDefault -Items $navgithub
# Running on Windows
if(($PSVersionTable.PSVersion.Major -lt 6) -or ($IsWindows)){
Write-Host "Running on Windows $($PSScriptRoot)"
# Add dynamic pages
foreach($item in (Get-ChildItem (Join-Path $PSScriptRoot -ChildPath 'pages'))){
. "$($item.FullName)"
}
# Add Listener to Tcp Port 8080 on localhost
$EPProperties = @{
Address = 'PodeWebApp'
Port = 8443
Protocol = 'https'
}
Add-PodeEndpoint @EPProperties -SelfSigned
# Start Browser
$Path = "microsoft-edge:$($EPProperties.Protocol)://$($EPProperties.Address):$($EPProperties.Port)/"
Start-Process $Path -WindowStyle maximized
}elseif($IsMacOS){
Write-Host "Running on Mac $($PSScriptRoot)"
# Add dynamic pages
foreach($item in (Get-ChildItem (Join-Path $PSScriptRoot -ChildPath 'pages') -Exclude 'win_*')){
. "$($item.FullName)"
}
# Add Listener to Tcp Port 8080 on localhost
$EPProperties = @{
Address = 'localhost'
Port = 8080
Protocol = 'http'
}
Add-PodeEndpoint @EPProperties
# Start Browser
$Path = "$($EPProperties.Protocol)://$($EPProperties.Address):$($EPProperties.Port)/"
Start-Process $Path
}elseif($IsLinux){
Write-Host "Running on Linux $($PSScriptRoot)"
# Add dynamic pages
foreach($item in (Get-ChildItem (Join-Path $PSScriptRoot -ChildPath 'pages') -Exclude 'win_*')){
. "$($item.FullName)"
}
# Add Listener to Tcp Port 8080 on localhost
$EPProperties = @{
Address = 'localhost'
Port = 8080
Protocol = 'http'
}
Add-PodeEndpoint @EPProperties
# Start Browser
$Path = "$($EPProperties.Protocol)://$($EPProperties.Address):$($EPProperties.Port)/"
Start-Process $Path
}
}