In this course we will learn to use Flash, which is a Python -based web development framework.
Flask is a minimalist framework with which it is very easy to make web applications. Even being minimalist, Flash can climb along with your projects as much as you need, of course you will need a little more knowledge but the possibility exists. Fortunately it is a framework that has enough functionalities to fulfill the most common tasks and in case you need something else you can make use of the bookstores that other users have created to make your application can do just what you need, that returns the entire process simpler, so there is nothing to worry about.
from flask import Flask
app = Flask ( __name__ )
@ app . route ( "/" )
def index ():
return "Hello World!"
if __name__ == "__main__" :
app . run ()Simple, isn't it? Well, let's start then, luck!
Welcome to the general course summary, here you can give you an idea of the content of each video and if you are looking for something specific because. Still we recommend that you look at each video so you can benefit from all the information.
Creating a Flash application is very simple, and start using it too, to do it we only need to serve it through a local server that we establish. In the latter we can choose in which port and host our application will be executed, among other things.
One of the most common activities is to create routes through which we carry out different actions. Whether dynamic or static routes we learned to create them, and analyze different characteristics of these, and even mention some tips to create them correctly.
A topic that is not complex at all and that we also do not speak much are the static files (CSS, JS, Favicon) because they do not correspond as such literally to the course, however, we still explain what they are and how to use them in conjunction with our application.
We can create web applications through Flash using different bases related to web development, however, many of the applications created today are for any common user to be used directly and to make this fulfill we are easy to easily use by the website showing the necessary information by HTML templates in which we can present different visual elements to the user so that they can make use of each of the functions that our functions offer. Achieving all this is quite simple, we prepare a directory and there we keep our templates, then to each route we assign a template to distribute, and voila!
Most HTML templates show static data, that is, they do not change, however we are creating a dynamic website where much of the information changes based on the data that is being handled in the server area (backend) and that in fact is the part that we are administering through Flash HTML and our application to give life to that information, and not only that but with Jinja we can also "program" in these templates. A quite powerful view engine and which there are many things to talk about, here we give you the basics to learn the use you can give (later there are more tutorials referring to Jinja).
In this type of applications we need to do that of a lot of data and many of them need to be stored, and then recover them and perform different operations with them for most cases to show them as information to a user. In a nutshell, we need data persistence and for this there are databases, this time we show you how to link to your application an MySQL database but using non-SQL language to administer it, so you don't even need to know SQL. (In later tutorials, more information about databases is shown).
Through the HTML forms we can recover data, and do something with that data in the server area, for example, store them in a database. Something very common on a website is to ask users to register in order to offer them a better experience during their visit, it is precisely this exercise we take: user management system, to explain all the elements and learn how to use forms for different methods, routes; even encrypt your data, make validations, etc. A quite important video because from now on many references to this exercise are made.
Making or not use of cookies on a website is something that is discussed very often for different issues such as safety, performance and user privacy. On this occasion we will not be playing the subject on that side but only learn to create them, read them, in short, to use them in a general way, and if you know what they are we give you some ideas so that you form your own and give them a use. (We recommend seeing the last video of the course because there is important information related to this topic) .
The sessions are related to cookies because the session itself is a cookie, but that these are easier to use because they have some default values. In them we can store different information, for example, save the data of an already registered user who has accessed our website with their data and then for example, check if the user is browsing our website through their account or not, among other things.
As we had already mentioned, working with routes is something of the most common in web applications, and two of the most required actions are: redirecting and appearing to different routes. We can achieve this in a simple way using the Redirect and URL_For functions, we can even use them together, and achieve benefit from other interesting characteristics they possess.
When a user uses our website, it is most likely that different actions are needed in the server area that subsequently yield a result, and a way of informing these results in a friendly way to the user is to use the flash messages. In fact I would dare to say that it is the most "friendly" way to do it, because these messages are usually striking and the user is not upset because they are shown spontaneously on the route where it is located.
When we are programming and notice that we do actions quite repetitively we create functions, and thus avoid repeating code, which translates into a better structured code while developing faster nustro project because we lose less time writing unnecessary code. This situation can be applied to the macros that although they are not the same as a function, because the advantages they offer us are similar, in this particular case we create macros through our Jinja view engine to create better organized HTML templates, more efficient, easy to update and all this in less time.
A quite short tutorial where we learn to avoid the white spaces left by our Jinja view engine when seeing/analyzing the HTML templates in a web browser. An issue of not as much relevance but that can be useful for tasks such as purifying templates, and improving their semantics.
On many occasions we need to perform different actions before, or after a request under different circumstances. It is in this part that we use these decorators, there are several of them but here we show you three of the most commonly used.
Sometimes it is necessary to move information through different contexts in our application, a simple way to do so is to use the global object that Flash provides to which we can add different methods and store information there, for example: save connections/operations of a database, the information of a user, etc. Something interesting about this object is that we can even use it through our Jinja view engine and execute different actions in our HTML templates, without even having to import it because this is done by default.
So far we have talked about websites created to be used by common users, but there are other web development bases that are used to create applications, one of the most popular bases is known as "Restful API" and in many cases these applications use JON structures to exchange data and carry out different tasks. Well, here we give you a brief introduction to it, explaining that they are the JON structures and how you can administer them through your flash application. There will be an exclusive course to create this type of applications .
Making use of Librebría in conjunction with your Flash application you can communicate with other applications, through the HTTP protocol and under the context of Restoful API. Recall that there will be an exclusive course for this type of applications but we still leave you a simple example to request resources served by another API.
Learn to upload files through your Flak application using HTML forms, something important on this topic is to take care of the type of files that are uploaded and for this we can make different security validations, because here we cover all that and even show you how to recover those files once they have been uploaded and show them through a route of your application.
Again, one of the most common things in web applications is to make use of different routes, and this is where we run into some more common mistakes, such as accessing a route that does not exist or enter an unauthorized route. Although default responses are returned, we can make such errors and return personalized answers, such as a personalized template to cover the famous 404 error (resource not found), or even a JSON with an objection that contains the error, that will already depend on the concept of our application.
Our application begins to grow after a while and that is why we must take the time to organize the tree of our application in some way that we can keep everything under control in a simpler way. There are several ways to organize a Flash application, this time we show you how to do it through the concept-modulation-importing concept. Another very important thing is the configuration palameters that our application needs to work, in the same way there are different practices to achieve it, here it is shown how to assign different configurations based on classes (development-production) and how to recover the configuration values in different ways (variables, files, objects, environment variables).
During the course, quite information was shown and addressed on many occasions in a different way, although this does not seem to me that it has been a problem because the repository of the Github course was always available from where you could take each of the projects that were generated throughout the course. In any way, this time there will be a brief summary of the course interactively showing a Flash application that has been created using most information that was widespread throughout the course. In fact, it is in this tutorial where you will be invited to read this same summary that you are reading so that you do not forget to include anything that has been taught in the course in your own project.
It was time to upload a Flash application to the cloud so that users can use it from their respective devices connected to the Internet, after all it is a web application. To make our Flash application available to the public there are different ways to do so, one of them is to use some third -party service. On this occasion we will do it through Pythonanywhere, a free and easy -to -use host.
While when we develop, SQLite3 is a good tool to handle our databases, the truth is that when placing our application in SQLite3 production we begin to fall short, so they make use of other services such as MySQL, dessertsql, Mongodb, among others. In the past tutorial we made use of Pythonanywhere to distribute our application, because in this same host we can configure our MySQL service for free, and then integrate that service with our Flash application without any problem.
We arrive at our end of the course, and there are still enough things to learn about Flak, but the basics are already and will be quite useful to follow the following tutorials and courses on it, so they are pending them. Of course, before the end of the course we must analyze some important issues about the applications that we can generate with all the knowledge we acquire during the course.
Important doubts :