Skip to content

Commit

Permalink
fix static dir
Browse files Browse the repository at this point in the history
  • Loading branch information
fzumstein committed Apr 30, 2024
1 parent 078bdd7 commit 11a192f
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 18 deletions.
9 changes: 7 additions & 2 deletions app/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
from pathlib import Path
from typing import List, Literal, Optional

from pydantic import computed_field
from pydantic_settings import BaseSettings, SettingsConfigDict


class Settings(BaseSettings):
model_config = SettingsConfigDict(
env_prefix="XLWINGS_", env_file=os.getenv("DOTENV_PATH", ".env")
env_prefix="XLWINGS_", env_file=os.getenv("DOTENV_PATH", ".env"), extra="ignore"
)
add_security_headers: bool = True
base_dir: Path = Path(__file__).resolve().parent
Expand All @@ -25,9 +26,13 @@ class Settings(BaseSettings):
hostname: Optional[str] = None
log_level: str = "INFO"
public_addin_store: bool = False
static_dir: Path = base_dir / "static"
license_key: str

@computed_field
@property
def static_dir(self) -> Path:
return self.base_dir / "static"


settings = Settings()

Expand Down
1 change: 1 addition & 0 deletions app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ async def root():


# Static files: in prod should be served via a HTTP server like nginx if possible
# See also pending ASGI branch in https://github.com/evansd/whitenoise
app.mount("/static", StaticFiles(directory=settings.static_dir), name="static")
if settings.environment == "development":
# Don't cache static files
Expand Down
3 changes: 0 additions & 3 deletions app/routers/manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@

@router.get("/manifest")
async def manifest(request: Request):
logger.info(os.environ)
logger.info(os.getenv("RENDER_EXTERNAL_URL"))
if settings.hostname:
# Settings
if settings.hostname.startswith("https://"):
Expand All @@ -25,7 +23,6 @@ async def manifest(request: Request):
elif os.getenv("RENDER_EXTERNAL_URL"):
# Render
base_url = os.getenv("RENDER_EXTERNAL_URL")
logger.info(base_url)
elif os.getenv("WEBSITE_HOSTNAME"):
# Azure Functions
base_url = os.getenv("WEBSITE_HOSTNAME")
Expand Down
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
22 changes: 9 additions & 13 deletions app/templates/manifest.xml
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<OfficeApp
xmlns="http://schemas.microsoft.com/office/appforoffice/1.1"
<OfficeApp xmlns="http://schemas.microsoft.com/office/appforoffice/1.1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:bt="http://schemas.microsoft.com/office/officeappbasictypes/1.0"
xmlns:ov="http://schemas.microsoft.com/office/taskpaneappversionoverrides"
xsi:type="TaskPaneApp">
xmlns:ov="http://schemas.microsoft.com/office/taskpaneappversionoverrides" xsi:type="TaskPaneApp">
<!-- TODO: Create your own ID via https://www.guidgen.com or by running in Python: import uuid;print(uuid.uuid4()) -->
<Id>0a856eb1-91ab-4f38-b757-23fbe1f73130</Id>
<Version>1.0.0</Version>
<ProviderName>xlwings</ProviderName>
<DefaultLocale>en-US</DefaultLocale>
<DisplayName DefaultValue="xlwings Server" />
<Description DefaultValue="xlwings Server" />
<IconUrl DefaultValue="{{ base_url }}/static/images/examples/xlwings-32.png" />
<HighResolutionIconUrl DefaultValue="{{ base_url }}/static/images/examples/xlwings-64.png" />
<IconUrl DefaultValue="{{ base_url }}/static/images/ribbon/examples/xlwings-32.png" />
<HighResolutionIconUrl DefaultValue="{{ base_url }}/static/images/ribbon/examples/xlwings-64.png" />
<SupportUrl DefaultValue="https://www.xlwings.org/contact" />
<AppDomains>
<AppDomain>{{ base_url }}</AppDomain>
Expand All @@ -31,9 +29,7 @@
<SourceLocation DefaultValue="{{ base_url }}/taskpane" />
</DefaultSettings>
<Permissions>ReadWriteDocument</Permissions>
<VersionOverrides
xmlns="http://schemas.microsoft.com/office/taskpaneappversionoverrides"
xsi:type="VersionOverridesV1_0">
<VersionOverrides xmlns="http://schemas.microsoft.com/office/taskpaneappversionoverrides" xsi:type="VersionOverridesV1_0">
<Hosts>
<Host xsi:type="Workbook">
<!-- Custom Functions -->
Expand All @@ -43,7 +39,7 @@
<AllFormFactors>
<ExtensionPoint xsi:type="CustomFunctions">
<Script>
<SourceLocation resid="Functions.Script.Url" />;
<SourceLocation resid="Functions.Script.Url" />
</Script>
<Page>
<SourceLocation resid="Taskpane.Url" />
Expand Down Expand Up @@ -119,9 +115,9 @@

<Resources>
<bt:Images>
<bt:Image id="Icon.16x16" DefaultValue="{{ base_url }}/static/images/examples/xlwings-16.png" />
<bt:Image id="Icon.32x32" DefaultValue="{{ base_url }}/static/images/examples/xlwings-32.png" />
<bt:Image id="Icon.80x80" DefaultValue="{{ base_url }}/static/images/examples/xlwings-80.png" />
<bt:Image id="Icon.16x16" DefaultValue="{{ base_url }}/static/images/ribbon/examples/xlwings-16.png" />
<bt:Image id="Icon.32x32" DefaultValue="{{ base_url }}/static/images/ribbon/examples/xlwings-32.png" />
<bt:Image id="Icon.80x80" DefaultValue="{{ base_url }}/static/images/ribbon/examples/xlwings-80.png" />
</bt:Images>
<bt:Urls>
<!-- This must point to the HTML document with the task pane -->
Expand Down

0 comments on commit 11a192f

Please sign in to comment.