The goal of the project is to deploy a replica of Airbnb website using my server It will not implement all the features, just some of them to cover all the fundamental concepts. In this case a command interpreter is created in this segment to manage objects for the AirBnB(HBnB) website.
- Create a new object as User or Place
- Retrieve an object from a file.
- Update attributes of an object
- Destroy an object
- Clone this repository
- Access AirBnb directory:
cd AirBnB_clone
- Run hbnb(interactively):
./console
and enter command - Run hbnb(non-interactively):
echo "<command>" | ./console.py
console.py - Contains the entry point of the command interpreter.
EOF
- Exits consolequit
- Exits console<emptyline>
- Does nothingcreate
- Creates a new instance of object and saves it into .JSON filedestroy
- Deletes an object from specific .JSON fileshow
- Prints the string representation of an specific object.all
- Prints all string representation of all available objects .update
- Updates an objects based on the class name and id.
base_model.py - The BaseModel class
def __init__(self, *args, **kwargs)
- Initialization of classdef __str__(self)
- String representation of the BaseModel classdef save(self)
- Updates the attributeupdated_at
with the current datetimedef to_dict(self)
- returns a dictionary containing all keys/values of the instance
file_storage.py - serializes and deserializes objects
def all(self)
- returns the dictionary __objectsdef new(self, obj)
- sets in __objects the obj with keydef save(self)
- serializes __objects to the JSON filedef reload(self)
- deserializes the JSON file to __objects
- Non-interactive mode
- Interactive mode