Skip to content

Instantly share code, notes, and snippets.

View agusrichard's full-sized avatar

Agus Richard Lubis agusrichard

View GitHub Profile
product = {
'name': 'Burger',
'description': 'The tastiest burger ever'
}
try:
print(f"{product['name']} costs {product['price']}")
except KeyError:
print('There is no product\'s name and price')
product = {
'price': 2000, # remove this to run the exception handling
'name': 'Burger',
'description': 'The tastiest burger ever'
}
try:
print(f"{product['name']} costs {product['price']}")
except:
print('There is no product\'s name and price')
product = {
'price': 2000,
'name': 'Burger',
'description': 'The tastiest burger ever'
}
if 'name' in product and 'price' in product:
print(f"{product['name']} costs {product['price']}")
else:
print('There is no product\'s name and price')
version: "3"
services:
server:
build:
context: .
dockerfile: Dockerfile
container_name: server
image: server
restart: always
volumes:
build:
docker-compose build
up:
docker-compose up
run:
docker-compose up --build
down:
version: "3"
services:
server:
build:
context: .
dockerfile: Dockerfile
container_name: server
image: server
restart: always
volumes:
FROM node
WORKDIR /usr/app
COPY package*.json ./
RUN npm install
COPY . ./
EXPOSE 5000
CMD npm run dev
"scripts": {
"build": "tsc",
"dev": "eslint --fix --ext .ts ./src && nodemon",
"lint": "eslint --fix --ext .ts ./src"
},
{
"watch": ["src"],
"ext": "ts, json",
"exec": "tsc && node ./build/index.js"
}
"scripts": {
"build": "tsc",
"dev": "node ./build/index.js",
"lint": "eslint --fix --ext .ts ./src"
},