Skip to content

feat: implement comprehensive local development environment with PR #169 website integration#188

Merged
uelkerd merged 8 commits into
mainfrom
feat/local-dev-server
Sep 27, 2025
Merged

feat: implement comprehensive local development environment with PR #169 website integration#188
uelkerd merged 8 commits into
mainfrom
feat/local-dev-server

Conversation

@uelkerd
Copy link
Copy Markdown
Owner

@uelkerd uelkerd commented Sep 27, 2025

Summary

Complete implementation of local development environment combining:

Key Features

🚀 Local Development Server

  • Flask server with CORS enabled for cross-origin requests
  • Automated startup script with dependency management and user-friendly output
  • Minimal dependencies (Flask + Flask-CORS only)
  • Health checks and comprehensive error handling
  • Port flexibility with environment variable support

🎨 Sophisticated Website Integration

  • Modern dark theme with glassmorphism design and CSS gradients
  • Interactive demo features: emotion detection, voice transcription, text summarization
  • Material Icons and professional UI components
  • Real-time processing console and progress indicators
  • Voice recording functionality with audio visualizer
  • Top 5 emotions visualization and detailed model analysis

📁 Files Added/Modified

Local Development Infrastructure:

  • deployment/local/simple_server.py - Flask server with CORS and security
  • deployment/local/start-simple.sh - User-friendly startup automation
  • deployment/local/requirements-simple.txt - Minimal dependencies
  • README.md - Updated local development instructions

Website Files (from PR #169):

  • website/index.html - Sophisticated homepage with inline CSS
  • website/comprehensive-demo.html - Interactive demo with DeBERTa v3 Large
  • website/css/comprehensive-demo.css - Advanced demo styling
  • website/js/comprehensive-demo.js - Main demo functionality
  • website/js/config.js - Configuration management
  • website/js/demo-initialization.js - Demo initialization
  • website/js/layout-manager.js - Layout state management
  • website/js/voice-recorder.js - Voice recording capability
  • website/favicon.ico - Professional favicon

Usage

# Start local development server
cd deployment/local
./start-simple.sh

# Or with custom port
PORT=8001 ./start-simple.sh

# Access website at http://localhost:8000

Technical Implementation

  • CORS Configuration: Development mode allows all origins for testing
  • Security Validation: Path traversal protection and file access controls
  • Error Handling: Comprehensive error responses with helpful debugging info
  • Performance: Optimized static file serving with Flask
  • Monitoring: Health endpoint for system status checks

Testing Completed

✅ Local server starts correctly and serves website files
✅ Health endpoint returns proper JSON response
✅ Main page loads with sophisticated dark theme design
✅ Comprehensive demo loads with DeBERTa v3 Large integration
✅ All JavaScript and CSS files load without errors
✅ Production GitHub Pages deployment remains functional

🤖 Generated with Claude Code

Summary by Sourcery

Implement a comprehensive local development environment by adding a lightweight Flask server, an automated startup script, and minimal requirements, alongside the integrated website files from PR #169 featuring interactive DeBERTa-powered demos.

New Features:

  • Add simple Flask-based local development server serving website files with CORS, security checks, and a health endpoint
  • Provide a startup shell script for automated dependency installation and server launch with port customization
  • Include interactive demo website assets (HTML, CSS, JS) integrating DeBERTa v3 Large for emotion detection, transcription, and summarization

Documentation:

  • Update README with local development instructions, server usage examples, and project structure

Summary by CodeRabbit

  • New Features

    • Introduced a minimal local web server for development: serves static site files, provides a health check endpoint, validates environment, supports configurable host/port, and applies CORS with origin whitelisting.
    • Added a streamlined startup flow for local runs, including automatic dependency installation and clear startup/status messages.
    • Defined a minimal dependency set to simplify local setup.
  • Documentation

    • Reworked the README with clearer phrasing, expanded notes, updated examples, and reorganized sections for easier navigation.

uelkerd and others added 2 commits September 27, 2025 10:00
Add comprehensive local development environment with Flask server, CORS support, and user-friendly startup process. Complete PR #169 vision with minimal dependencies and production-ready local testing.

Key additions:
- deployment/local/simple_server.py: Flask server with health checks and CORS
- deployment/local/start-simple.sh: Automated startup with dependency management
- deployment/local/requirements-simple.txt: Minimal Flask + CORS dependencies
- README.md: Updated local development instructions

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
Update README.md with comprehensive local development instructions including the new Flask development server for website testing with CORS support.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings September 27, 2025 08:24
@sourcery-ai
Copy link
Copy Markdown
Contributor

sourcery-ai Bot commented Sep 27, 2025

Reviewer's Guide

Introduces a standalone Flask-based local development server with CORS configuration, health checks, and security measures; adds an automated startup script with minimal dependencies; integrates the sophisticated website demo assets from PR #169; and updates documentation to guide the new local development workflow.

File-Level Changes

Change Details Files
Local development server implementation
  • New Flask app serving static website files with CORS and environment-based origin restrictions
  • Endpoints for health check and custom 404/500 error handling
  • Security measures preventing path traversal and controlling file access
  • CLI args and env var support for port, host, and debug mode
deployment/local/simple_server.py
Automated startup and dependency management
  • Bash script to install minimal deps and launch the server with port checks
  • Virtual environment detection and user-friendly feedback on dependencies
  • Strict bash options for fail-fast behavior
deployment/local/start-simple.sh
deployment/local/requirements-simple.txt
Integration of sophisticated website demo assets
  • Added interactive demo pages with DeBERTa v3 Large integration and dark glassmorphism theme
  • Introduced CSS styling and JS modules for config, initialization, layout, and voice recording
  • Included favicon and enhanced UI components
website/index.html
website/comprehensive-demo.html
website/css/comprehensive-demo.css
website/js/comprehensive-demo.js
website/js/config.js
website/js/demo-initialization.js
website/js/layout-manager.js
website/js/voice-recorder.js
website/favicon.ico
Documentation enhancements
  • Updated README.md with local setup instructions and usage examples
  • Reformatted markdown tables and blockquotes for consistency
  • Added local development workflow details for both website and API
README.md

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Sep 27, 2025

Warning

Rate limit exceeded

@uelkerd has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 17 minutes and 28 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 4ed509f and 7707b31.

📒 Files selected for processing (2)
  • deployment/local/simple_server.py (1 hunks)
  • deployment/local/start-simple.sh (1 hunks)

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Walkthrough

Introduces a minimal local development server setup: adds a Flask-based static file server, a startup shell script to install dependencies and launch it, a minimal requirements file, and textual updates to README. Includes health endpoint, CORS handling, index/static routes, and environment validation.

Changes

Cohort / File(s) Summary
Documentation
README.md
Reworded and reorganized content; formatting and examples updated. No code or API changes.
Local dev server (Flask)
deployment/local/requirements-simple.txt, deployment/local/simple_server.py, deployment/local/start-simple.sh
Added minimal dependency spec, a Flask static server with CORS, health, and error handlers, plus a robust Bash launcher handling env checks, dependency install, port selection, and server startup.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant Dev as Developer
  participant Sh as start-simple.sh
  participant Pip as pip
  participant Py as python3
  participant Srv as simple_server.py (Flask)

  Dev->>Sh: Execute start-simple.sh
  Sh->>Sh: Validate directory, Python, requirements file
  Sh->>Pip: Install requirements (user or venv)
  Sh->>Sh: Determine PORT, warn if in use
  Sh->>Py: Run python3 simple_server.py --port PORT
  Py->>Srv: Initialize Flask app
  Srv->>Srv: validate_environment(), configure CORS
  note right of Srv: Routes: /, /<file>, /health<br/>Errors: 404, 500 (JSON)
  Dev-->>Srv: Access http://host:PORT/
Loading
sequenceDiagram
  autonumber
  participant Client
  participant Flask as Flask App
  participant FS as Website Directory

  Client->>Flask: GET /
  alt index.html exists
    Flask->>FS: Read index.html
    FS-->>Flask: File contents
    Flask-->>Client: 200 HTML (+CORS if allowed)
  else missing
    Flask-->>Client: 404 JSON
  end

  Client->>Flask: GET /<path>
  Flask->>Flask: Security check (within WEBSITE_DIR)
  alt Allowed and file exists
    Flask->>FS: Read file
    FS-->>Flask: Contents
    Flask-->>Client: 200 (+CORS if allowed)
  else
    Flask-->>Client: 404 JSON
  end

  Client->>Flask: GET /health
  Flask-->>Client: 200 JSON (status, dir, mode, pages)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested reviewers

  • sourcery-ai

Poem

I twitch my whiskers, server spins with grace,
Flask-y burrows mapped to each web place.
CORS like a fence, but friendly and neat,
Health checks thump—a steady beat.
With bashy paws I start the show—
Port 8000, ready to go! 🐇✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title accurately highlights the main addition of a comprehensive local development environment and acknowledges the accompanying website integration, both of which are central to this PR. Although it includes an internal PR reference, it remains descriptive of the substantive changes made.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @uelkerd, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request establishes a robust local development environment for the SAMO Deep Learning project. It enables developers to easily run a local web server that hosts the project's interactive website, complete with advanced features like emotion detection and voice transcription, and seamlessly test it against live Cloud Run APIs. This setup significantly enhances the development and testing workflow by providing a self-contained, production-like environment on a local machine.

Highlights

  • New Local Development Server: Introduces a Flask-based local development server (simple_server.py) with CORS support, designed for testing the website against production Cloud Run APIs.
  • Automated Setup Script: Adds a start-simple.sh script to automate the installation of minimal dependencies and the startup of the local server, improving developer experience.
  • Website Integration: Incorporates sophisticated website files (from PR feat: Add comprehensive demo website with DeBERTa v3 Large integration #169) into the local environment, featuring a modern UI, interactive demos, and DeBERTa v3 Large integration.
  • Updated Documentation: The README.md has been updated to include detailed instructions for setting up and using the new local website development server.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements a comprehensive local development environment that enables testing the website against production APIs. The changes combine a sophisticated website interface from PR #169 with a Flask-based local development server that handles CORS and static file serving.

  • Adds Flask-based development server with CORS support for cross-origin testing
  • Integrates sophisticated website files featuring DeBERTa v3 Large emotion detection
  • Provides automated startup scripts and minimal dependency management for easy local development

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
deployment/local/start-simple.sh Automated startup script with dependency management and user-friendly output
deployment/local/simple_server.py Flask server with CORS, security validation, and comprehensive error handling
deployment/local/requirements-simple.txt Minimal dependency specification for the local development server
README.md Updated documentation with local development instructions and usage examples

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@deepsource-io
Copy link
Copy Markdown
Contributor

deepsource-io Bot commented Sep 27, 2025

Here's the code health analysis summary for commits 50eeca1..7707b31. View details on DeepSource ↗.

Analysis Summary

AnalyzerStatusSummaryLink
DeepSource Test coverage LogoTest coverage⚠️ Artifact not reportedTimed out: Artifact was never reportedView Check ↗
DeepSource Python LogoPython✅ SuccessView Check ↗
DeepSource Terraform LogoTerraform✅ SuccessView Check ↗
DeepSource Secrets LogoSecrets✅ SuccessView Check ↗
DeepSource Shell LogoShell✅ SuccessView Check ↗
DeepSource Docker LogoDocker✅ SuccessView Check ↗

💡 If you’re a repository administrator, you can configure the quality gates from the settings.

Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey there - I've reviewed your changes and they look great!

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location> `deployment/local/simple_server.py:78-85` </location>
<code_context>
+        file_path = WEBSITE_DIR / filename
+
+        # Security check: ensure file is within website directory
+        file_path.resolve().relative_to(WEBSITE_DIR.resolve())
+
+        if file_path.is_file():
</code_context>

<issue_to_address>
**🚨 suggestion (security):** Consider handling symlink traversal for static file serving.

Symlinks within the website directory could expose files outside the intended scope. Consider restricting symlink serving or clarifying the expected behavior.

```suggestion
        # Restrict serving symlinks for security
        if file_path.is_symlink():
            return jsonify({
                "error": "Symlinks are not allowed",
                "file": filename,
                "path": str(file_path)
            }), 403

        if file_path.is_file():
            return send_file(file_path)
        else:
            return jsonify({
                "error": "File not found",
                "file": filename,
                "path": str(file_path)
            }), 404
```
</issue_to_address>

### Comment 2
<location> `deployment/local/start-simple.sh:54-19` </location>
<code_context>
+PORT="${PORT:-8000}"
+
+# Check if port is available
+if command -v netstat >/dev/null 2>&1; then
+    if netstat -an | grep -q ":$PORT "; then
+        echo "⚠️  Warning: Port $PORT appears to be in use"
+        echo "You can set a different port with: PORT=8001 $0"
+    fi
+fi
+
</code_context>

<issue_to_address>
**suggestion:** Port availability check may not work on all platforms.

Since netstat may not be present or consistent across all operating systems, consider adding lsof or ss as alternatives, or clarify in documentation that this check may not be universally reliable.

Suggested implementation:

```
# Check if port is available (tries netstat, lsof, or ss; may not be universally reliable)

```

```
if command -v netstat >/dev/null 2>&1; then
    if netstat -an | grep -q ":$PORT "; then
        echo "⚠️  Warning: Port $PORT appears to be in use"
        echo "You can set a different port with: PORT=8001 $0"
    fi
elif command -v lsof >/dev/null 2>&1; then
    if lsof -iTCP:"$PORT" -sTCP:LISTEN -Pn | grep -q LISTEN; then
        echo "⚠️  Warning: Port $PORT appears to be in use"
        echo "You can set a different port with: PORT=8001 $0"
    fi
elif command -v ss >/dev/null 2>&1; then
    if ss -ltn | grep -q ":$PORT "; then
        echo "⚠️  Warning: Port $PORT appears to be in use"
        echo "You can set a different port with: PORT=8001 $0"
    fi
else
    echo "ℹ️  Port availability check skipped: no suitable tool (netstat, lsof, ss) found."
fi

```
</issue_to_address>

### Comment 3
<location> `deployment/local/simple_server.py:167` </location>
<code_context>
def main():
    """Main entry point."""
    parser = argparse.ArgumentParser(description="SAMO Local Development Server")
    parser.add_argument("--port", type=int, default=int(os.getenv("PORT", 8000)),
                       help="Port to run the server on (default: 8000)")
    parser.add_argument("--host", default="127.0.0.1",
                       help="Host to bind to (default: 127.0.0.1)")
    parser.add_argument("--debug", action="store_true",
                       help="Enable debug mode")

    args = parser.parse_args()

    print("🚀 SAMO Local Development Server")
    print("=" * 40)

    # Validate environment
    if not validate_environment():
        sys.exit(1)

    print(f"📁 Serving files from: {WEBSITE_DIR}")
    print(f"🌐 Server URL: http://{args.host}:{args.port}")
    print(f"🔗 Direct links:")
    print(f"   • Main page: http://{args.host}:{args.port}/")

    # List available HTML files
    html_files = list(WEBSITE_DIR.glob("*.html"))
    for html_file in html_files:
        if html_file.name != "index.html":
            print(f"   • {html_file.stem.title()}: http://{args.host}:{args.port}/{html_file.name}")

    print(f"🏥 Health check: http://{args.host}:{args.port}/health")
    print("\nPress Ctrl+C to stop the server")
    print("=" * 40)

    try:
        app.run(
            host=args.host,
            port=args.port,
            debug=args.debug,
            threaded=True
        )
    except KeyboardInterrupt:
        print("\n👋 Server stopped by user")
    except Exception as e:
        print(f"❌ Server error: {e}")
        sys.exit(1)

</code_context>

<issue_to_address>
**suggestion (code-quality):** Replace f-string with no interpolated values with string ([`remove-redundant-fstring`](https://docs.sourcery.ai/Reference/Default-Rules/refactorings/remove-redundant-fstring/))

```suggestion
    print("🔗 Direct links:")
```
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread deployment/local/simple_server.py Outdated
Comment thread deployment/local/start-simple.sh
Comment thread deployment/local/simple_server.py Outdated
Comment thread deployment/local/simple_server.py Fixed
Comment thread deployment/local/simple_server.py Fixed
Comment thread deployment/local/simple_server.py Fixed
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a comprehensive local development environment, including a lightweight Flask server, an automated startup script, and the necessary dependencies. The changes are well-implemented and significantly improve the local development workflow. The Flask server includes good security practices like CORS configuration and path traversal protection. The startup script is user-friendly, handling dependency installation and providing helpful output. I have one suggestion to simplify the file-serving logic in simple_server.py to make it more idiomatic and maintainable. Overall, this is a solid contribution.

Comment thread deployment/local/simple_server.py Outdated
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 50eeca1 and 4ed509f.

📒 Files selected for processing (4)
  • README.md (16 hunks)
  • deployment/local/requirements-simple.txt (1 hunks)
  • deployment/local/simple_server.py (1 hunks)
  • deployment/local/start-simple.sh (1 hunks)
🧰 Additional context used
🪛 markdownlint-cli2 (0.18.1)
README.md

60-60: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


68-68: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


74-74: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


82-82: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


89-89: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


270-270: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


276-276: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


283-283: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


373-373: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)

🪛 GitHub Check: CodeQL
deployment/local/simple_server.py

[failure] 76-76: Uncontrolled data used in path expression
This path depends on a user-provided value.


[failure] 78-78: Uncontrolled data used in path expression
This path depends on a user-provided value.


[failure] 79-79: Uncontrolled data used in path expression
This path depends on a user-provided value.

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Sourcery review

Comment thread deployment/local/simple_server.py Outdated
- Add symlink traversal protection to static file serving
- Improve port availability check for cross-platform compatibility (netstat, lsof, ss)
- Remove redundant f-string formatting
- Fix PORT environment variable validation to handle non-integer values gracefully

Security: Prevents serving symlinks that could expose files outside website directory
Reliability: Better port checking across different operating systems
Code quality: Cleaner string formatting and robust error handling
- Combine serve_index and serve_file functions into single function
- Use Flask's built-in send_from_directory for better security and maintainability
- Leverage Flask's built-in path traversal protection
- Reduce code complexity and improve readability

The send_from_directory function provides the same security protections
against path traversal attacks while being more idiomatic Flask code.
- Prefix unused error parameters with underscore to indicate intentional non-use
- Fixes PYL-W0613 linting warnings for not_found and server_error functions
- Maintains Flask error handler signature requirements while indicating unused args

This follows Python best practices for unused parameters in callback functions.
- Fix FLK-E128 formatting issues in argument parser
- Align help text continuation lines with proper visual indentation
- Improve code readability and comply with flake8 standards

This ensures consistent indentation for multi-line function arguments.
- Break long lines to comply with 88-character limit
- Extract URL construction to separate variable for readability
- Simplify available_files logic in 404 error handler
- Improve code formatting and maintainability

This ensures compliance with flake8 line length standards.
- Break long comment line to comply with 79-character docstring limit
- Improve readability by splitting comment across multiple lines
- Maintains same information while following style guidelines

This ensures compliance with flake8 docstring formatting standards.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants