Holbertonbnb is a complete full-stack web application, integrating a MySQL database and Flask RESTful API with a dynamic HTML5/CSS3/jQuery front-end.
This proyect was do it along 4 differents proyects. In each one we create a different feature to manage and learn new tools to build this proyect. For this reason we will explain each feature more bellow in the readme.
-
Models class system built in Python.
-
Python console to manage back-end models
-
Flask web application server rendering HTML templates with Jinja2
-
RESTful Flask API
- Source code
- Swagger documentation - bdbnb.site/apidocs
-
Automatic deployment scripts.
Application:
Tool/Library | Version |
---|---|
Python | ^3.6.4 |
MySQL | ^5.6.0 |
Flask | ^1.0.3 |
flasgger | ^0.9.2 |
Flask-Cors | ^3.0.8 |
mysqlclient | ^1.3.10 |
SQLAlchemy | ^1.3.5 |
Deployment:
Tool/Library | Version |
---|---|
Python | ^3.7.3 |
gunicorn | ^19.9.0 |
Fabric | ^2.4.0 |
Puppet | ^5.4.0 |
The console is the first segment of the AirBnB project at Holberton School that will collectively cover fundamental concepts of higher level programming. The goal of AirBnB project is to eventually deploy our server a simple copy of the AirBnB Website(HBnB). A command interpreter is created in this segment to manage objects for the AirBnB(HBnB) website.
- Create a new object (ex: a new User or a new Place)
- Retrieve an object from a file, a database etc...
- Do operations on objects (count, compute stats, etc...)
- Update attributes of an object
- Destroy an object
This project is interpreted/tested on Ubuntu 14.04 LTS using python3 (version 3.4.3)
- Clone this repository:
git clone "https://github.com/alexaorrico/AirBnB_clone.git"
- Access AirBnb directory:
cd AirBnB_clone
- Run hbnb(interactively):
./console
and enter command - Run hbnb(non-interactively):
echo "<command>" | ./console.py
console.py - the console contains the entry point of the command interpreter. List of commands this console current supports:
EOF
- exits consolequit
- exits console<emptyline>
- overwrites default emptyline method and does nothingcreate
- Creates a new instance ofBaseModel
, saves it (to the JSON file) and prints the iddestroy
- Deletes an instance based on the class name and id (save the change into the JSON file).show
- Prints the string representation of an instance based on the class name and id.all
- Prints all string representation of all instances based or not on the class name.update
- Updates an instance based on the class name and id by adding or updating attribute (save the change into the JSON file).
vagrantAirBnB_clone$./console.py
(hbnb) help
Documented commands (type help <topic>):
========================================
EOF all create destroy help quit show update
(hbnb) all MyModel
** class doesn't exist **
(hbnb) create BaseModel
7da56403-cc45-4f1c-ad32-bfafeb2bb050
(hbnb) all BaseModel
[[BaseModel] (7da56403-cc45-4f1c-ad32-bfafeb2bb050) {'updated_at': datetime.datetime(2017, 9, 28, 9, 50, 46, 772167), 'id': '7da56403-cc45-4f1c-ad32-bfafeb2bb050', 'created_at': datetime.datetime(2017, 9, 28, 9, 50, 46, 772123)}]
(hbnb) show BaseModel 7da56403-cc45-4f1c-ad32-bfafeb2bb050
[BaseModel] (7da56403-cc45-4f1c-ad32-bfafeb2bb050) {'updated_at': datetime.datetime(2017, 9, 28, 9, 50, 46, 772167), 'id': '7da56403-cc45-4f1c-ad32-bfafeb2bb050', 'created_at': datetime.datetime(2017, 9, 28, 9, 50, 46, 772123)}
(hbnb) destroy BaseModel 7da56403-cc45-4f1c-ad32-bfafeb2bb050
(hbnb) show BaseModel 7da56403-cc45-4f1c-ad32-bfafeb2bb050
** no instance found **
(hbnb) quit
No known bugs at this time.
HTML files for HolbertonBnB are rendered by this application server, built in Python Flask and using Jinja2.
templates: The HTML5 content for HolbertonBnB.
- templates/index.html: The root page of HolbertonBnB.
- static: Static content included in templates/index.html.
- static/images: Image files.
- static/scripts: JavaScript scripts (uses jQuery).
- static/images: CSS3 stylesheets.
Assuming the above dependencies have been installed, the app server can be started using the following command:
python3 web_flask.app
No known bugs at this time.
The complete documentation for the API can be read using Swagger documentation - bdbnb.site/apidocs.
All file use the different endpoint inside de api/v1/views.
Assuming the above dependencies have been installed, the API can be started using the following command:
python3 api.v1.app
No known bugs at this time.
Fabric and Puppet scripts for automatically, remotely deploying HolbertonBnB.
-
setup_server.pp: Puppet manifest that configures a web server for deployment of HolbertonBnB.
- Usage:
sudo puppet apply setup_server.pp
(note thatsudo
privileges are required). - Ensures installation of Nginx, copies in an Nginx configuration file, and runs the service.
- Creates the directory
/data
to store the application, set the proper permissions.
- Usage:
-
fabfile.py: Fabric fabfile to deploy HolbertonBnB to a web server.
- Run
fab --list
to list all available commands. - Usage:
fab <script> --<option>=<value>
- Options:
pack --folder=STR
: Creates a tar archive.upload --archive=STR
: Distributes a tar archive.pack-and-upload --folder=STR
: Creates and distributes a tar archive.restart
: Restarts the WSGI apps.deploy --folder=STR
: All of the above for a given folder(s).
- Run
No known bugs at this time.
Alexa Orrico - Github / Twitter
Jennifer Huang - Github / Twitter
Jhoan Zamora - Github / Twitter
David Ovalle - Github / Twitter
Angel Pedroza - Github / Twitter
Michael Cocuy - Github
Second part of Airbnb: Joann Vuong
Public Domain. No copy write protection.