Giter Site home page Giter Site logo

airbnb_clone_v2's Introduction

The AirBnB Clone Project

AirBnB Logo Project Description

The AirBnB clone project backend interfaced by a console application with the help of the cmd module in python.

Data (python objects) generated are stored in a json file and accessed with the help of the json module in python Description of the command interpreter:

Works like Bash shell except that this has a limited number of accepted commands that were solely defined for the purposes of the usage of the AirBnB website.

This command line interpreter serves as the frontend of the web app where users can interact with the backend which was developed with python OOP programming.

Some of the commands available are:

show
create
update
destroy
count

And as part of the implementation of the command line interpreter coupled with the backend and file storage system, the folowing actions can be performed:

Creating new objects (ex: a new User or a new Place)
Retrieving an object from a file, a database etc…
Doing operations on objects (count, compute stats, etc…)
Updating attributes of an object
Destroying an object

How to start it

These instructions will get you a copy of the project up and running on your local machine (Linux distro) for development and testing purposes. Installing

You will need to clone the repository of the project from Github. This will contain the simple shell program and all of its dependencies.

git clone https://{PERSONAL-TOKEN}github.com/Alphaeu/AirBnB_clone.git

After cloning the repository you will have a folder called AirBnB_clone. In here there will be several files that allow the program to work.

/console.py : The main executable of the project, the command interpreter.

models/engine/file_storage.py: Class that serializes instances to a JSON file and deserializes JSON file to instances

models/__ init __.py: A unique FileStorage instance for the application

models/base_model.py: Class that defines all common attributes/methods for other classes.

models/user.py: User class that inherits from BaseModel

models/state.py: State class that inherits from BaseModel

models/city.py: City class that inherits from BaseModel

models/amenity.py: Amenity class that inherits from BaseModel

models/place.py: Place class that inherits from BaseModel

models/review.py: Review class that inherits from BaseModel

How to use it

Works in two modes:

Interactive and Non-interactive.

In Interactive mode, the console will display a prompt (hbnb) indicating that the user can write and execute a command. After the command is run, the prompt will appear again a wait for a new command. This can go indefinitely as long as the user does not exit the program.

$ ./console.py (hbnb) help

Documented commands (type help ):

EOF help quit

(hbnb) (hbnb) (hbnb) quit $

In Non-interactive mode, the shell will need to be run with a command input piped into its execution so that the command is run as soon as the Shell starts. In this mode no prompt will appear, and no further input will be expected from the user.

$ echo "help" | ./console.py (hbnb)

Documented commands (type help ):

EOF help quit (hbnb) $ $ cat test_help help $ $ cat test_help | ./console.py (hbnb)

Documented commands (type help ):

EOF help quit (hbnb) $

Format of Command Input

In order to give commands to the console, these will need to be piped through an echo in case of Non-interactive mode.

In Interactive Mode the commands will need to be written with a keyboard when the prompt appears and will be recognized when an enter key is pressed (new line). As soon as this happens, the console will attempt to execute the command through several means or will show an error message if the command didn't run successfully. In this mode, the console can be exited using the CTRL + D combination, CTRL + C, or the command quit or EOF. Arguments

Most commands have several options or arguments that can be used when executing the program. In order for the Shell to recognize those parameters, the user must separate everything with spaces.

Example:

user@ubuntu:/AirBnB$ ./console.py (hbnb) create BaseModel 49faff9a-6318-451f-87b6-910505c55907 user@ubuntu:/AirBnB$ ./console.py

or

user@ubuntu:/AirBnB$ ./console.py $ echo "create BaseModel" | ./console.py (hbnb) e37ebcd3-f8e1-4c1f-8095-7a019070b1fa (hbnb) user@ubuntu:/AirBnB$ ./console.py

Available commands and what they do

The recognizable commands by the interpreter are the following: Command Description quit or EOF Exits the program Usage By itself


help Provides a text describing how to use a command. Usage By itself --or-- help


create Creates a new instance of a valid Class, saves it (to the JSON file) and prints the id. Valid classes are: BaseModel, User, State, City, Amenity, Place, Review. Usage create


show Prints the string representation of an instance based on the class name and id Usage show --or-- .show()


destroy Deletes an instance based on the class name and id (saves the change into a JSON file). Usage destroy --or-- .destroy()


all Prints all string representation of all instances based or not on the class name. Usage By itself or all --or-- .all()


update Updates an instance based on the class name and id by adding or updating attribute (saves the changes into a JSON file). Usage update "" ---or--- .update(, , ) --or-- .update(, )


count Retrieve the number of instances of a class. Usage .count() Authors

Derrick Alphaeus| Email:[email protected]

airbnb_clone_v2's People

Contributors

alphaeu avatar

Watchers

 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.