GithubHelp home page GithubHelp logo

devdocker's Introduction

Dockerized Python Server for Toronto Time

This repository contains a Dockerfile and a Python script (server.py) to run a simple HTTP server that returns the current time in Toronto as JSON for GET requests. The server is built using Python 3.11 and is dockerized for easy deployment.

Setup

To build and run the Docker container: Ensure you have Docker installed on your system. Clone this repository to your local machine. Navigate to the root directory of the repository. Building the Docker Image To build the Docker image, run the following command:

docker build -t toronto-time-server .
Running the Docker Container

Once the image is built, you can run the Docker container using the following command:

docker run -d -p 8010:8010 toronto-time-server

This will start the HTTP server inside the container, listening on port 8010. You can access the server at http://localhost:8010.

Usage Once the server is running, you can send GET requests to http://localhost:8010 to retrieve the current time in Toronto in JSON format.

Example request:
curl http://localhost:8010
Example response:
{
  "TorontoTime": "2024-02-15 12:00:00"
}

Server Implementation Details

The server is implemented using Python's built-in http.server module. It creates a simple HTTP server that handles GET requests by returning the current time in Toronto timezone as JSON.

The logic for calculating the Toronto time is done by subtracting 5 hours from the current UTC time.

Directory Structure

Dockerfile: Defines the Docker image for the server. server.py: Contains the implementation of the HTTP server. README.md: This file.

Contributions

Contributions to improve or extend this project are welcome! If you encounter any issues or have suggestions for enhancements, please feel free to open an issue or submit a pull request.

License

This project is licensed under the MIT License.

devdocker's People

Watchers

Maziar avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.