"Hello World" API docker image built using FastAPI and Python
- Running on port 8080 default
- Quick run using docker:
docker run -it --rm --network host raushanraja/fastapi-hello-world:latest
This application uses the following environment variables, which can be customized:
HOST
: (Default:0.0.0.0
) - The default host address.PORT
: (Default:8080
) - The default port number.RELOAD
: (Default:True
) - A boolean indicating whether reload is enabled (True
orFalse
).
-
Run the Docker container with customized configuration:
docker run -e HOST="YOUR_HOST" -e PORT="YOUR_PORT" -e RELOAD="YOUR_RELOAD_VALUE" raushanraja/fastapi-hello-world:latest
Replace
YOUR_HOST
,YOUR_PORT
, andYOUR_RELOAD_VALUE
with your desired values.HOST
: Specify the desired host address.PORT
: Specify the port number.RELOAD
: Set toTrue
orFalse
based on your requirements.
-
Run using docker-comopose:
version: '3' services: fastapi: image: raushanraja/fastapi-hello-world:latest ports: - "8080:8080" environment: - HOST=0.0.0.0 - PORT=8080 - RELOAD=False
docker-compose up
- Description: Returns a "Hello World" message using the GET method.
- Endpoint:
http://localhost:8080/
- Return JSON:
{ "message": "Hello World", "method": "GET" }
- Description: Returns a "Hello World" message using the POST method.
- Endpoint:
http://localhost:8080/
- Return JSON:
{ "message": "Hello World", "method": "POST" }
- Description: Returns a "Hello World" message using the PUT method.
- Endpoint:
http://localhost:8080/
- Return JSON:
{ "message": "Hello World", "method": "PUT" }
- Description: Returns a "Hello World" message using the DELETE method.
- Endpoint:
http://localhost:8080/
- Return JSON:
{ "message": "Hello World", "method": "DELETE" }
- Description: Returns a "Hello World" message using the PATCH method.
- Endpoint:
http://localhost:8080/
- Return JSON:
{ "message": "Hello World", "method": "PATCH" }
- Description: Returns a "Hello World" message using the OPTIONS method.
- Endpoint:
http://localhost:8080/
- Return JSON:
{ "message": "Hello World", "method": "OPTIONS" }
- Description: Returns a "Hello World" message using the HEAD method.
- Endpoint:
http://localhost:8080/
- Return JSON:
{ "message": "Hello World", "method": "HEAD" }
- Description: Returns a "Hello World" message using the TRACE method.
- Endpoint:
http://localhost:8080/
- Return JSON:
{ "message": "Hello World", "method": "TRACE" }