- Create folder and file
.\Tools\<ToolName>\<ToolName>Pages.ps1 with the Add-PodeWebPage code inside.
- Put other files you need in the same folder.
- Add to
Config.Example.ps1 a new section under Tools with:
@{
...
Tools = @{
...
ToolName = @{
# Enable/Disable this tool.
Enable = $true
OtherConfigYouNeed = 'Example value'
}
}
}
- The page code will be loaded if the tool config Enable is true.
- To access the config use
$Config['Tools']['ToolName'] or (Get-PodeConfig).
- Available extra functions:
$RelativePath | Get-PwtRootedPath if you need to add root to relative path (relative to the Home.ps1 folder).
Add-PodeStaticRoute @RouteParams splat $RouteParams when adding a Route to set its EndpointName and Authentication if they where configured by the user.
Set-PodeResponseAttachment @AttachmentParams splat (Get-PodeConfig)['Global']['AttachmentParams'] to set its EndpointName if they where configured by the user.
Import-Module @ImportParams splat $ImportParams when adding a Module to set -Force if "Debug" is on for easier reloading while developing. You can also copy Server.Example.psd1 to Server.psd1 for auto reloading on file change.
- To use the SQLite, use
Connect-Sql in the beginning of the runspace to establish a confection for the first time then run queries with Invoke-Sql -QueryPath '\Path\File.sql' -QueryFormat Param.
- To generate a file and download it, you can use the
DownloadPath config and the /download route, for example excel:
$DownloadPath = (Get-PodeConfig)['Global']['DownloadPath']
$PathLeaf = Join-Path (New-Guid).Guid ('Data {0:yyyy-MM-dd HH-mm-ss}.xlsx' -f (Get-Date))
Export-Excel -InputObject $Data -TableName 'Data' -AutoSize -Path (Join-Path $DownloadPath $PathLeaf)
$AttachmentParams = (Get-PodeConfig)['Global']['AttachmentParams']
Set-PodeResponseAttachment -Path ('/download', ($PathLeaf.Replace('\', '/')) -join '/') @AttachmentParams