Ida  Nader

Ida Nader

1593581050

Build a Property Booking Website with Starlette, MongoDB, and Twilio

As developers we often have the ability to choose our own tools to get the job done. If you’re like me, any time a new framework builds up a reputation for high performance, you jump right in to see what the developer experience is like. In today’s article, I want to look at building a web application with a Python ASGI framework called Starlette that promises blazing fast performance and developer productivity. We’ll put Starlette to the test by integrating MongoDBStitch, and Twilio into the mix to build an AirBnB-type property booking application.

If you would like to follow along with this tutorial, you can get the code from the GitHub repo. Also, be sure to sign up for a free MongoDB Atlas account to make it easier to connect your MongoDB database. Use code ADO200 to receive a $200 credit. In this tutorial, we’ll make use of a sample dataset that is provided by MongoDB Atlas.

What is Starlette

Starlette is a Python ASGI framework that shines. It is a fairly new framework but has already garnered the attention of many Python developers for its high performance, support for WebSocketsGraphQL, impressive 100% test coverage, and zero hard dependencies.

Starlette LogoThe framework is very light and easy to work with. The really impressive thing about Starlette is that it can be treated either as either an entire framework, or just a toolkit, where components can be independently utilized in your existing framework or application. For this tutorial, we’ll treat Starlette as a framework and build our entire application with Starlette. For this tutorial, I’ll assume you are familiar with Python, but if you need a refresher, there’s no better place than the official Python tutorial.

Today’s Project: MongoBnB

Today we are going to be building a rental reservation system, similar to AirBnB, that we’ll conveniently name MongoBnB. Our application will display a list of featured properties, allow the user to sort by various parameters, view additional details of a selected property, and finally book and cancel reservations.

MongoBnBWe have a lot to do today, so let’s dive right into it!

Building Our Dataset

As I mentioned at the beginning of this article, we are going to use a sample dataset provided by MongoDB Atlas. If you don’t already have an account, sign up for free here (and use code ADO200for a $200 credit), and create a new cluster. Once you have a cluster up and running, whether it’d be new or existing, load the sample dataset by clicking on the three dots button to see additional options, and then select “Load Sample Dataset.”

Load Sample DatasetThe sample dataset provided by MongoDB Atlas will create a number of collections containing various datasets. Navigate to the Collections tab to see them all. All of the datasets will be created as separate databases prefixed with sample_ and then the name of the dataset. It may take a few minutes for all of the databases to be imported, but the one we care about for our application is called sample_airbnb. Open this database up and you’ll see one collection called listingsAndReviews. Click on it to see the data we will be working with.

Sample AirBnB DatasetThis collection will have over 5,000 documents, with each containing all the information we could ever want for a particular listing. For our application, we’ll only work with a subset of the data, but you will have lots of existing data to expand on in case you wish to add additional features beyond the scope of the tutorial. Look around the dataset and familiarize yourself with it a little bit. Run a few filter queries such as {"price": {"$lt":10}} or {"review_scores.review_scores_rating":100} to find some really affordable properties or some of the highest rated ones respectively.

Now that we have our dataset ready, let’s get to writing some Python.

Setting Up Our Starlette Application

To get started with Starlette, we’ll need to install it. Python’s pip package manager can help with this. Open up your terminal and run the command pip3 install starlette. Starlette by itself is not a server so we’ll need to install an ASGI server as well. There’s many options like uvicorndaphne, or hypercorn, and for our tutorial we’ll use uvicorn. If you don’t already have uvicorn installed, run the command pip3 install uvicorn and we’ll be off to the races.

While we’re installing dependencies, let’s install one final one that we’ll need for our application and that is Jinja. Jinja is a templating engine for Python that we’ll use to render our application to the browser. Run pip3 install jinja2 to install it. This is an optional dependency for the Starlette framework, if you’re just planning on using Starlette to serve an API with JSON responses for example, then you could omit this step, but for our tutorial, we’ll make use of it.

Hello Starlette

Now that we have our dependencies installed, we’re ready to write some code. Create a new python file called app.py. This will be our main entry point into our Starlette application. To get started, let’s setup the most basic Starlette application to ensure that all of our dependencies were installed correctly. Write the following code:

1
2
3
4
5
6
7
8
9
10
from starlette.applications import Starlette
from starlette.routing import Route
from starlette.responses import PlainTextResponse

async def homepage(request):
  return PlainTextResponse("Hello from Starlette")

app = Starlette(debug=True, routes=[
    Route('/', homepage),
])

copy code

The code above imports the Starlette framework, or various toolkit components if you will, such as routing and responses. Then on line 8 we create an instance of our Starlette application. For our app we’ll want the debugging to be on so we have detailed error reports, and for the second parameter we pass in our routes. For this test app, we’re only going to have one route and we’ll call it homepage. Finally, we implement this homepage route and all it does is display the message “Hello from Starlette” to the users browser.

Let’s make sure our app works. Since we installed uvicorn as our ASGI server, we’ll use it to start up our application. In the terminal execute the command uvicorn app:app in the directory where your app.py file resides. This will start up the default server on localhost:8000. You will get a message in the terminal saying that the Uvicorn server is running if everything went ok, if you have issues at this point, ensure that all of the above pip packages are installed. Check out the uvicorn docs page for troubleshooting.

If all went well and the server is up and running, navigate to localhost:8000 in your browser and you’ll see the message “Hello from Starlette.” Congrats! You just built your first Starlette application. Now let’s build something real.

#mongodb

What is GEEK

Buddha Community

Build a Property Booking Website with Starlette, MongoDB, and Twilio

Query of MongoDB | MongoDB Command | MongoDB | Asp.Net Core Mvc

https://youtu.be/FwUobnB5pv8

#mongodb tutorial #mongodb tutorial for beginners #mongodb database #mongodb with c# #mongodb with asp.net core #mongodb

Install MongoDB Database | MongoDB | Asp.Net Core Mvc

#MongoDB
#Aspdotnetexplorer

https://youtu.be/cnwNWzcw3NM

#mongodb #mongodb database #mongodb with c# #mongodb with asp.net core #mongodb tutorial for beginners #mongodb tutorial

Ida  Nader

Ida Nader

1593581050

Build a Property Booking Website with Starlette, MongoDB, and Twilio

As developers we often have the ability to choose our own tools to get the job done. If you’re like me, any time a new framework builds up a reputation for high performance, you jump right in to see what the developer experience is like. In today’s article, I want to look at building a web application with a Python ASGI framework called Starlette that promises blazing fast performance and developer productivity. We’ll put Starlette to the test by integrating MongoDBStitch, and Twilio into the mix to build an AirBnB-type property booking application.

If you would like to follow along with this tutorial, you can get the code from the GitHub repo. Also, be sure to sign up for a free MongoDB Atlas account to make it easier to connect your MongoDB database. Use code ADO200 to receive a $200 credit. In this tutorial, we’ll make use of a sample dataset that is provided by MongoDB Atlas.

What is Starlette

Starlette is a Python ASGI framework that shines. It is a fairly new framework but has already garnered the attention of many Python developers for its high performance, support for WebSocketsGraphQL, impressive 100% test coverage, and zero hard dependencies.

Starlette LogoThe framework is very light and easy to work with. The really impressive thing about Starlette is that it can be treated either as either an entire framework, or just a toolkit, where components can be independently utilized in your existing framework or application. For this tutorial, we’ll treat Starlette as a framework and build our entire application with Starlette. For this tutorial, I’ll assume you are familiar with Python, but if you need a refresher, there’s no better place than the official Python tutorial.

Today’s Project: MongoBnB

Today we are going to be building a rental reservation system, similar to AirBnB, that we’ll conveniently name MongoBnB. Our application will display a list of featured properties, allow the user to sort by various parameters, view additional details of a selected property, and finally book and cancel reservations.

MongoBnBWe have a lot to do today, so let’s dive right into it!

Building Our Dataset

As I mentioned at the beginning of this article, we are going to use a sample dataset provided by MongoDB Atlas. If you don’t already have an account, sign up for free here (and use code ADO200for a $200 credit), and create a new cluster. Once you have a cluster up and running, whether it’d be new or existing, load the sample dataset by clicking on the three dots button to see additional options, and then select “Load Sample Dataset.”

Load Sample DatasetThe sample dataset provided by MongoDB Atlas will create a number of collections containing various datasets. Navigate to the Collections tab to see them all. All of the datasets will be created as separate databases prefixed with sample_ and then the name of the dataset. It may take a few minutes for all of the databases to be imported, but the one we care about for our application is called sample_airbnb. Open this database up and you’ll see one collection called listingsAndReviews. Click on it to see the data we will be working with.

Sample AirBnB DatasetThis collection will have over 5,000 documents, with each containing all the information we could ever want for a particular listing. For our application, we’ll only work with a subset of the data, but you will have lots of existing data to expand on in case you wish to add additional features beyond the scope of the tutorial. Look around the dataset and familiarize yourself with it a little bit. Run a few filter queries such as {"price": {"$lt":10}} or {"review_scores.review_scores_rating":100} to find some really affordable properties or some of the highest rated ones respectively.

Now that we have our dataset ready, let’s get to writing some Python.

Setting Up Our Starlette Application

To get started with Starlette, we’ll need to install it. Python’s pip package manager can help with this. Open up your terminal and run the command pip3 install starlette. Starlette by itself is not a server so we’ll need to install an ASGI server as well. There’s many options like uvicorndaphne, or hypercorn, and for our tutorial we’ll use uvicorn. If you don’t already have uvicorn installed, run the command pip3 install uvicorn and we’ll be off to the races.

While we’re installing dependencies, let’s install one final one that we’ll need for our application and that is Jinja. Jinja is a templating engine for Python that we’ll use to render our application to the browser. Run pip3 install jinja2 to install it. This is an optional dependency for the Starlette framework, if you’re just planning on using Starlette to serve an API with JSON responses for example, then you could omit this step, but for our tutorial, we’ll make use of it.

Hello Starlette

Now that we have our dependencies installed, we’re ready to write some code. Create a new python file called app.py. This will be our main entry point into our Starlette application. To get started, let’s setup the most basic Starlette application to ensure that all of our dependencies were installed correctly. Write the following code:

1
2
3
4
5
6
7
8
9
10
from starlette.applications import Starlette
from starlette.routing import Route
from starlette.responses import PlainTextResponse

async def homepage(request):
  return PlainTextResponse("Hello from Starlette")

app = Starlette(debug=True, routes=[
    Route('/', homepage),
])

copy code

The code above imports the Starlette framework, or various toolkit components if you will, such as routing and responses. Then on line 8 we create an instance of our Starlette application. For our app we’ll want the debugging to be on so we have detailed error reports, and for the second parameter we pass in our routes. For this test app, we’re only going to have one route and we’ll call it homepage. Finally, we implement this homepage route and all it does is display the message “Hello from Starlette” to the users browser.

Let’s make sure our app works. Since we installed uvicorn as our ASGI server, we’ll use it to start up our application. In the terminal execute the command uvicorn app:app in the directory where your app.py file resides. This will start up the default server on localhost:8000. You will get a message in the terminal saying that the Uvicorn server is running if everything went ok, if you have issues at this point, ensure that all of the above pip packages are installed. Check out the uvicorn docs page for troubleshooting.

If all went well and the server is up and running, navigate to localhost:8000 in your browser and you’ll see the message “Hello from Starlette.” Congrats! You just built your first Starlette application. Now let’s build something real.

#mongodb

How WordPress Helps you Make Great Websites in 2020

Many sites are powered by a CMS (Content Management System) called WordPress. WordPress is an Open Source Software that offers free use of the product.

This is awesome for a low budget business or individual. To learn more about WordPress or there terms visit their website (wordpress.org).

Before you launch, your WordPress site go through this checklist to get a better understanding

I will assume you have already purchased a domain name and had a hosting account set up with a service provider.

Many service providers are willing to go as far as installing WordPress for you now.

WordPress is great, but you must also learn about how websites work. Beginners should start by learning HTML (HyperText Markup Language) and CSS (Cascading Style Sheets).

These two computer languages basically cover how things are arranged and displayed on a page.

You should also understand how the FTP protocol is used for transferring files to your HTTP server.

Once you have got a good feel of HTML, CSS, HTTP, and FTP you will be ready to start exploring WordPress.

It allows you to change the look and feel of your website through a backside control panel.

You will find that WP is very robust and scalable.

It can provide a solution ranging from a single web page to an expansive multi-page website.

Another cool thing about WP is how it offers database solutions like pages, categories, comments, etc.

You can use it as a Blog or you can create static web pages. I am a huge fan. I have tried JOOMLA, but I still prefer WP.

There is a lot to learn when you are considering building a website.

I have been using WP for about 5 years and I am still learning. There is plenty of documentation available on the net.

If you are in need of a website, and you are starting this from scratch, I would recommend hiring a developer. But if you can accomplish learning this you will be able to build a good website solution for almost anyone.

#wordpress #wordpress-website #web-development #wordpress-website-building #wordpress-website-development #wordpress-tutorial #website #website-development

Rahim Makhani

Rahim Makhani

1620968589

Get a Bug Free and smooth website with website Maintenance

Having a website for your own firm or business is very important as it can benefit you in many ways like your users can get 24/7 service from your company, you can exchange your information, it can help you to expand your business in the market. One must also maintain their website to keep it bug free and updated.

Your website should be bug free because if there is any bug in your website it will slow down the performance of it and will not even work properly if this happens then there are chances that you may lose your customers.

Are you searching for a company that can provide you with website support and maintenance? Nevina Infotech is the best company that can help you with the maintenance and support, as we have enthusiastic web app developers who can help you to maintain your website.

#website maintenance services #website support and maintenance #website maintenance support #website maintenance packages #website maintenance company #website maintenance plans