Python Programming Blueprints
eBook - ePub

Python Programming Blueprints

Daniel Furtado, Marcus Pennington

Compartir libro
  1. English
  2. ePUB (apto para móviles)
  3. Disponible en iOS y Android
eBook - ePub

Python Programming Blueprints

Daniel Furtado, Marcus Pennington

Detalles del libro
Vista previa del libro
Índice
Citas

Información del libro

How to build useful, real-world applications in the Python programming languageAbout This Book• Deliver scalable and high-performing applications in Python.• Delve into the great ecosystem of Python frameworks and libraries through projects that you will build with this book.• This comprehensive guide will help you demonstrate the power of Python by building practical projects.Who This Book Is ForThis book is for software developers who are familiar with Python and want to gain hands-on experience with web and software development projects. A basic knowledge of Python programming is required.What You Will Learn• Learn object-oriented and functional programming concepts while developing projects• The dos and don'ts of storing passwords in a database• Develop a fully functional website using the popular Django framework• Use the Beautiful Soup library to perform web scrapping• Get started with cloud computing by building microservice and serverless applications in AWS• Develop scalable and cohesive microservices using the Nameko framework• Create service dependencies for Redis and PostgreSQLIn DetailPython is a very powerful, high-level, object-oriented programming language. It's known for its simplicity and huge community support. Python Programming Blueprints will help you build useful, real-world applications using Python.In this book, we will cover some of the most common tasks that Python developers face on a daily basis, including performance optimization and making web applications more secure. We will familiarize ourselves with the associated software stack and master asynchronous features in Python. We will build a weather application using command-line parsing. We will then move on to create a Spotify remote control where we'll use OAuth and the Spotify Web API. The next project will cover reactive extensions by teaching you how to cast votes on Twitter the Python way. We will also focus on web development by using the famous Django framework to create an online game store. We will then create a web-based messenger using the new Nameko microservice framework. We will cover topics like authenticating users and, storing messages in Redis.By the end of the book, you will have gained hands-on experience in coding with Python.Style and approachWith a hands-on approach, Python Programming Blueprints guides you through diverse real-life projects to get you started; it presents most aspects of the Python programming language gradually, going from basic to advanced topics.

Preguntas frecuentes

¿Cómo cancelo mi suscripción?
Simplemente, dirígete a la sección ajustes de la cuenta y haz clic en «Cancelar suscripción». Así de sencillo. Después de cancelar tu suscripción, esta permanecerá activa el tiempo restante que hayas pagado. Obtén más información aquí.
¿Cómo descargo los libros?
Por el momento, todos nuestros libros ePub adaptables a dispositivos móviles se pueden descargar a través de la aplicación. La mayor parte de nuestros PDF también se puede descargar y ya estamos trabajando para que el resto también sea descargable. Obtén más información aquí.
¿En qué se diferencian los planes de precios?
Ambos planes te permiten acceder por completo a la biblioteca y a todas las funciones de Perlego. Las únicas diferencias son el precio y el período de suscripción: con el plan anual ahorrarás en torno a un 30 % en comparación con 12 meses de un plan mensual.
¿Qué es Perlego?
Somos un servicio de suscripción de libros de texto en línea que te permite acceder a toda una biblioteca en línea por menos de lo que cuesta un libro al mes. Con más de un millón de libros sobre más de 1000 categorías, ¡tenemos todo lo que necesitas! Obtén más información aquí.
¿Perlego ofrece la función de texto a voz?
Busca el símbolo de lectura en voz alta en tu próximo libro para ver si puedes escucharlo. La herramienta de lectura en voz alta lee el texto en voz alta por ti, resaltando el texto a medida que se lee. Puedes pausarla, acelerarla y ralentizarla. Obtén más información aquí.
¿Es Python Programming Blueprints un PDF/ePUB en línea?
Sí, puedes acceder a Python Programming Blueprints de Daniel Furtado, Marcus Pennington en formato PDF o ePUB, así como a otros libros populares de Informatique y Programmation en Python. Tenemos más de un millón de libros disponibles en nuestro catálogo para que explores.

Información

Año
2018
ISBN
9781786464903
Edición
1
Categoría
Informatique

Online Video Game Store with Django

I was born in the late seventies, which means that I grew up during the birth of the video game industry. My first video game console was the Atari 2600, and it was because of that specific video game console that I decided that I wanted to be a programmer and make video games. I never got a job within the gaming industry, however, but I still love playing video games, and in, my spare time, I try to develop my own games.
To this day, I still go around the internetespecially eBaybuying old video games to bring back my nice childhood memories when all the family, my parents, and my sister, used to play Atari 2600 games together.
Because of my interest in vintage video games, we are going to develop a vintage video game online store; this will be a great way to develop something fun and also learn a lot about web development with the popular Django web framework.
In this chapter, we will cover the following:
  • Setting up the environment
  • Creating a Django project
  • Creating Django apps
  • Exploring the Django admin interface
  • Learning how to create an application model and perform queries with the Django ORM
Also, as an extra, we will be using the npm (Node Package Manager) to download the client-side dependencies. We will also cover how to create simple tasks using the task runner Gulp.
To make our application prettier without a lot of effort, we are going to use Bootstrap.
So, let's get started!

Setting up the development environment

As usual, we are going to start setting up the environment for development. In Chapter 4, Exchange Rates and the Currency Conversion Tool, you were introduced to pipenv, so in this and the following chapters, we are going to be using pipenv to create our virtual environment and manage our dependencies.
First, we want to create the directory where we are going to keep our project. In your working directory, create a directory called django-project as follows:
mkdir django-project && cd django-project
Now we can run pipenv to create our virtual environment:
pipenv --three
If you have Python 3 installed in another location, you can use the argument --python and specify the path where the Python executable is located. If everything went fine, you should see an output such as the following:
Now we can activate our virtual environment using the pipenv command shell:
pipenv shell
Great! The only dependency that we are going to add for now is Django.
At the time of writing this book, Django 2.0 had been released. It has really nice features compared to its predecessor. You can see the list of new features at https://docs.djangoproject.com/en/2.0/releases/2.0/.
Let's install Django in our virtual environment:
pipenv install django
Django 2.0 has dropped support for Python 2.0, so if you are planning to develop an application using Python 2, you should install Django 1.11.x or lower. I strongly recommend that you start a new project using Python 3. Python 2 will stop being maintained after a couple of years, and new packages will be created for Python 3. Popular packages of Python 2 will migrate to Python 3.
In my opinion, the best new feature of Django 2 is the new routing syntax, because now it is not necessary to write regular expressions. It is much cleaner and more readable to write something like the following:
path('user/<int:id>/', views.get_user_by_id)
The previous syntax relied more on regular expressions:
url('^user/?P<id>[0-9]/$', views.get_user_by_id)
It is much simpler this way. Another feature that I really like in Django 2.0 is that they have improved the admin UI a little bit and made it responsive; this is a great feature, because I have experienced that creating a new user (while you are on the go with no access to a desktop) on a non-responsive site on a small mobile phone screen can be painful.

Installing Node.js

When it comes to web development, it is almost impossible to stay away from Node.js. Node.js is a project that was released back in 2009. It is a JavaScript runtime that allows us to run JavaScript on the server-side. Why do we care about Node.js if we are developing a website using Django and Python? The reason is that the Node.js ecosystem has several tools that will help us to manage the client-side dependencies in a simple manner. One of these tools that we are going to use is the npm.
Think about npm as the pip of the JavaScript world. npm, however, has many more features. One of the features that we are going to use is npm scripts.
So, let's go ahead and install Node.js. Usually, developers need to go over to the Node.js website and download it from there, but I find it much simpler to use a tool called NVM, which allows us to install and switch easily between different versions of Node.js.
To install NVM in our environment, you can follow the instructions at https://github.com/creationix/nvm.
We are covering installation of NVM on Unix/Linux and macOS systems. If you are using Windows, there's an awesome version for Windows that has been developed in the Go language; it can be found at https://github.com/coreybutler/nvm-windows.
When NVM is installed, you are ready to install the latest version of Node.js with the following command:
nvm install node
You can verify if the installation is correct with the command:
node --version
While writing this book, the latest Node.js version is v8.8.1.
You can also type npm on the terminal, where you should see an output similar to the output that follows:

Creating a new Django project

To create a new Django project, run the following command:
django-admin startproject gamestore
Note that ...

Índice