Acebots-AI / my-tiny-service

0 stars 1 forks source link

Add endpoint that returns current timestamp #30

Closed artmoskvin closed 4 months ago

artmoskvin commented 4 months ago

The timestamp should have the ISO format

acebots-ai[bot] commented 4 months ago

Based on the project outline, here's a plan for implementing an endpoint that returns the current timestamp in ISO format:

  1. Create a New Endpoint in root.py:

    • Since root.py already contains a simple endpoint, it's a suitable place to add a new endpoint for returning the current timestamp.
    • Define a new function get_timestamp() that will handle requests to this endpoint.
  2. Implement Timestamp Logic:

    • Inside the get_timestamp() function, use Python's datetime module to get the current time and format it to ISO format using the isoformat() method.
  3. Register the New Endpoint:

    • Use the router object in root.py to register the new endpoint. This involves calling router.get() (or a similar method depending on the desired HTTP method) and passing the path and the endpoint function (get_timestamp).
  4. Update API Documentation (Optional):

    • Add a docstring to the get_timestamp() function to describe the endpoint. FastAPI automatically uses these docstrings to generate API documentation.
  5. Test the New Endpoint:

    • Add a new test case in tests/test_api.py to ensure the new endpoint returns the correct timestamp format and responds as expected.

This plan outlines the steps needed to add the new endpoint to the existing FastAPI application structure, ensuring it integrates smoothly with the current setup.

artmoskvin commented 4 months ago

@acedev-ai looks good, please proceed

acebots-ai[bot] commented 4 months ago

The implementation for the new endpoint that returns the current timestamp in ISO format has been completed, and a pull request has been created. You can review and merge the changes from this pull request.