Acebots-AI / my-tiny-service

0 stars 1 forks source link

Add endpoint that returns current timestamp #34

Closed sprokofyev closed 4 months ago

sprokofyev commented 4 months ago

Use 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 does not require any input parameters.
  2. Implement Timestamp Logic:

    • Inside the get_timestamp() function, use Python's datetime module to get the current timestamp.
    • Format the timestamp in ISO 8601 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) and passing the path you want to use for the endpoint (e.g., /timestamp) along with the get_timestamp function as the handler.
  4. Update Tests:

    • Add a new test function in tests/test_api.py to verify that the new timestamp endpoint returns a 200 status code and the correct timestamp format.
    • This test should make a request to the new endpoint and check that the response is in ISO 8601 format.
  5. Documentation and Comments:

    • Ensure that the new endpoint and the test are well-documented with comments explaining their purpose and functionality.
    • Update any relevant documentation to include the new endpoint.

This plan outlines the steps needed to add the requested feature to the project.