Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test images are not being served from _run.py #1

Open
Rufshod opened this issue Nov 17, 2023 · 0 comments
Open

Test images are not being served from _run.py #1

Rufshod opened this issue Nov 17, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@Rufshod
Copy link
Contributor

Rufshod commented Nov 17, 2023

In Anvil, Form TestForm should update get_test_url function to get the served the correct images.

Related code in _run.py:

# TEST IMAGE
@app.route("/test/<angle>/<image>")
def get_test_image(angle: str, image: str) -> Union[str, Response]:
    """
    Retrieve an image from the test directory.

    Args:
        angle (str): The angle of the camera.
        image (str): The name of the image file.

    Returns:
        Union[str, Response]: The image file or an error message.
    """
    directory = os.path.join(
        os.getcwd(), "data_warehouse", "dataset", object_name, "test", "good", angle
    )
    full_path = os.path.join(directory, image)
    print("Full path to image:", full_path)
    # Add a cache-busting query parameter
    cache_buster = request.args.get("cb", int(time.time()))

    if os.path.isfile(os.path.join(directory, image)):
        response = send_from_directory(directory, image)

        # Modify the cache control headers
        response.headers["Cache-Control"] = "no-store"
        return response
    else:
        return "File not found", 404
    ```
@Rufshod Rufshod added the bug Something isn't working label Nov 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant