Skip to content

Commit

Permalink
Merge branch 'main' into feature/shares
Browse files Browse the repository at this point in the history
  • Loading branch information
pjbedard committed Sep 10, 2024
2 parents a395800 + 7074d7d commit c89c4ec
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 6 deletions.
30 changes: 30 additions & 0 deletions abilities/aws/0.1.0/metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"id": "aws",
"name": "Amazon Web Services",
"versions": {
"package": "0.1.0",
"product": "1.35"
},
"description": "Amazon Web Services (AWS) integration",
"author": {
"name": "Amazon Web Services (AWS)",
"url": "https://aws.amazon.com/sdk-for-python/"
},
"maintainer": {
"name": "Sam Johnston",
"email": "samj@samj.net",
"url": "https://samjohnston.org"
},
"language": "python",
"license": "MIT",
"dependencies": [
{
"type": "python",
"id": "boto3",
"name": "Boto3",
"versions": {
"required": ">=1.35.0"
}
}
]
}
24 changes: 18 additions & 6 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,31 @@
from starlette.staticfiles import StaticFiles
from backend.redirector import redirector

# set up logging
from common.log import get_logger
logger = get_logger(__name__)

def create_app():
app = create_backend_app()
add_redirector_app(app)
add_frontend_app(app)
return app

def add_frontend_app(app):
# Add a route for serving static files
# Add a route for serving static files if the frontend dist directory exists
static_dir = Path(__file__).parent / 'frontend' / 'dist'
app.add_url_rule(
'/{path:path}',
endpoint='frontend',
view_func=StaticFiles(directory=static_dir, html=True)
)
if static_dir.is_dir():
# Add a route for serving static files only if the directory exists
app.add_url_rule(
'/{path:path}',
endpoint='frontend',
view_func=StaticFiles(directory=static_dir, html=True)
)
else:
logger.info(f"Skipping serving frontend: {static_dir} directory not found. Options:")
logger.info("- Use 'npm run build' to generate the frontend")
logger.info("- Use 'npm run dev' to run it separately")
logger.info("- Use the API only")

def add_redirector_app(app):
# Add a route for handling URL redirection for bot access
Expand All @@ -25,3 +36,4 @@ def add_redirector_app(app):
endpoint='redirector',
view_func=redirector
)

0 comments on commit c89c4ec

Please sign in to comment.