How can I become
a web developer using Python on the back end?
Python is easy to pick up, but you must stand on your feet before you start to run.
Python is an easy, flexible and powerful general purpose programming language (which is specially suited for web development), but you should bear in mind that in order to become a web developer you must learn several different skills besides python.
The first basic skill you must learn is HTML.
HTML is the markup language of the web. All web pages are created with HTML, which defines the different elements contained in a web page.
Then you should learn CSS, which is another little language that defines the way each HTML element looks within a page (its color, the font type, its position on the page, etc).
And the third skill you should master to become a complete web developer is javascript.
Javascript is a scripting language, just as python, but it runs within the browser.
It is a fundamental part of HTML5 (the newest incarnation of the HTML markup language, which powers all the new applications being written for the web and mobile phones and tablets (iphone, ipad, blackberry, etc...).
HTML + CSS + JAVASCRIPT are different parts of the whole HTML5 platform, and they all work in tandem to create a full web application.
Where does Python fit in?
Although you can create a full web application with just HTML, CSS and javascript, chances are that your application will need to access data stored in a server, most likely a database.
That means that you will have to write code that will be run in a remote server rather than in the browser.
The server side is different than the browser (or client side). In the client side you only have one option: javascript.
On the other hand, you can use any imaginable language on the server side.
People use php, java, ruby, python, c#, etc...
Python will let you talk to the database or datastore, perform queries, retrieve information and format the output to your web page.
Is it possible to forget about javascript and write your whole application in python?
Yes, and many web sites work this way. But you would be limiting yourself (and your website usability).
Think about it:
Code written in javascript runs in your browser (it doesn't need to communicate with a distant server and wait for the response) hence, its faster, and the user experience is better. That's why the new HTML5 web applications feel more and more like desktop applications.
Applications written entirely in javascript that talk directly to the database are known as Ajax applications.
But code written on the server side may give you more security and scalability, so both sides should be mastered to become a competent web developer.
As for web development frameworks:
Again, please first stand on your feet... When you reach the moment where you find yourself needing a framework, you will probably find out that you can get by with a simpler solution rather than Django.
Django lets you create the whole structure of your website on the server side.
My advice: Forget about all these things, get a good python tutorial and learn it (and enjoy it!) before looking at all the other technologies you will need.
Don't take this too seriously, but ...
-
create file name
app.pywith the following content:fromflaskimportFlaskapp =Flask(__name__)@app.route("/")defhello():return"Hello World!"if__name__ =="__main__":app.run() -
$ pip installFlask$ python app.py*Runningon http://localhost:5000/ -
Now you can visit your first web app under localhost, port 5000.
That
would be your first python web application. Everything after that is
"refinement" in application structure, functionality and
appearance.
---
I
can't give you a recommendation on a holistic class, but I can give
you some recommendations on individual pieces/parts. First, I
think that Django is a great framework for learning Python web
programming. It has great documentation and
support.
https://docs.djangoproject.com/e...
http://www.djangobook.com/
Working through the tutorial will give you a good understanding of what Django can do. Also, reading through the Django book will give you a good understanding of the additional features of Django.
My personal opinion is to start with a project in mind and start coding. PyCharm is a good editor and it is only $29 for students. It even gives you some good tools for CSS and HTML. Otherwise, PyDev is a pretty good Eclipse based editor.
The next steps are dependent on how interactive you want to make your web applications. If you don't care about doing a lot of fancy AJAX stuff, then you can probably do a lot of what you want with CSS, HTML and Django. I worked through my first few applications without needing any JavaScript. You can build some great applications with Django without ever needing to touch JavaScript.
If you do want more dynamic applications, I would suggest working through some jQuery tutorials ((http://docs.jquery.com/Main_Page). Combining Django and jQuery is really simple. For the most part, the Django portions of my application really don't affect the jQuery portions.
From my own experience, this worked out fairly well. I learned web development on my own outside of any class room setting. I started out working through the Django tutorials and books and did fine.
I am sorry if I didn't give you a good, one-stop-shop for learning Python web development. In my experience, frontend development and backend development are orthogonal efforts. I generally do a few mockups using standalone HTML, CSS, and JavaScript. Once, I get the look and feel right, I convert that HTML over to a Django template.
https://docs.djangoproject.com/e...
http://www.djangobook.com/
Working through the tutorial will give you a good understanding of what Django can do. Also, reading through the Django book will give you a good understanding of the additional features of Django.
My personal opinion is to start with a project in mind and start coding. PyCharm is a good editor and it is only $29 for students. It even gives you some good tools for CSS and HTML. Otherwise, PyDev is a pretty good Eclipse based editor.
The next steps are dependent on how interactive you want to make your web applications. If you don't care about doing a lot of fancy AJAX stuff, then you can probably do a lot of what you want with CSS, HTML and Django. I worked through my first few applications without needing any JavaScript. You can build some great applications with Django without ever needing to touch JavaScript.
If you do want more dynamic applications, I would suggest working through some jQuery tutorials ((http://docs.jquery.com/Main_Page). Combining Django and jQuery is really simple. For the most part, the Django portions of my application really don't affect the jQuery portions.
From my own experience, this worked out fairly well. I learned web development on my own outside of any class room setting. I started out working through the Django tutorials and books and did fine.
I am sorry if I didn't give you a good, one-stop-shop for learning Python web development. In my experience, frontend development and backend development are orthogonal efforts. I generally do a few mockups using standalone HTML, CSS, and JavaScript. Once, I get the look and feel right, I convert that HTML over to a Django template.
We
can't really tell you what to do.
The
fact is, we don't know what tools you would rather use, or what will
work better for you. I'm going to be really general here, so bear
with me:
-
Learn HTML, CSS, and Javascript. Before you do any kind of server-side programming, this is a must. You can't build a webpage without HTML, CSS makes it look pretty, and JS makes it dynamic. Also, it wouldn't hurt to add on some jQuery.
-
Install a web server, or find a free web host online. You don't need to pay for one. You're still learning. Personally, I have a WAMP server running on my desktop since I don't put anything into production, and I advise you to do the same.
-
Get coding! I cannot stress this enough. The only way to learn is by doing. You can't just read a book. If you want, do a few projects (e.g. a forum, a phonebook, etc.) to make it fun!
This
was a very general
walk-through of what you need to do. There is still the matter of
learning SQLbefore
a server-side language, and how to use a database, and all that good
stuff. But that's fairly easy to figure out with Stack Overflow and
Google! Until then, good luck!
HTML
(à comprendre avant tous les autres domaines) : un site très bien
>>> http://www.w3schools.com/tags/default.asp
-
connaitre par coeur les commandes head, meta, body, p, pre, br, hr, form, label, input, select, textarea, img, ul, dl, table, caption, fieldset, iframe, map. Gardez les commandes style, div et span pour quand vous étudierez le CSS.
-
connaitre les commandes HTML5 (nav, header, footer...)
-
comprendre la différence entre POST et GET
-
comprendre les différents doctype. TRES IMPORTANT. Si votre bouquin ne parle pas de <!DOCTYPE html> c'est qu'il est trop vieux.
-
comprendre les histoires d'encodage caractères (UTF8 et iso-8859-1 principalement). TRES IMPORTANT.
-
savoir ce qu'est une entête
-
savoir déclarer un style en ligne, dans le header et dans un fichier externe
-
comprendre les commandes style, div et span
-
comprendre la notion d'héritage
-
comprendre la différence entre . et # (très important)
-
comprendre la différence entre margin et padding >>> http://www.w3schools.com/css/css_boxmodel.asp
-
comprendre la différence entre les éléments inline et les éléments block (très important)
-
comprendre comment fonctionnent les float (très important). Comprendre la commande clear
-
comprendre la différence entre positionnement relatif et absolu. (très important)
-
comprendre les commandes de visibilité >>> http://www.w3schools.com/css/css_display_visibility.asp
-
comprendre la notion de sprite
PHP (remplacer par Python)
-
comprendre les require et include
-
comprendre la différence entre _POST, _GET et _REQUEST
-
comprendre les sessions et les cookies
-
comprendre les tableaux multidimensionnels et savoir bien les utiliser
-
comprendre les types de variables et savoir les modifier
-
connaitre la différence entre la programmation procédurale et objet. Je conseille quand on débute de ne pas faire tout de suite d'objet.
-
chaque fois que vous testez une commande, LISEZ la documentation EN ANGLAIS sur http://php.net/ et LISEZ les commentaires. C'est très formateur.
-
a vos moment de creux, fureter sur cette page http://php.net/manual/fr/indexes.functions.php et essayer de comprendre une fonction inconnue.
MYSQL
-
savoir utiliser phpmyadmin
-
savoir à partir de PHP ajouter/modifier/supprimer des données dans 2 tables liées
-
comprendre les histoires d'encodage caractères (UTF8 et iso-8859-1 principalement). TRES IMPORTANT.
-
comprendre la différence entre mysql_query, mysqli_query et PDO_MYSQL
-
comprendre le modèle relationnel et la différence entre une liaison 1:1, 1:n et n:n (TRES IMPORTANT).
-
comprendre à quoi servent les conventions de nommage et LES APPLIQUER. Ne surtout pas faire l'impasse si vous comptez être pro >>> http://sqlpro.developpez.com/cours/standards/
Javascript - Je donnerai juste un but à atteindre de 2 manières (avec et sans Jquery). Cela vous mettra le pied à l'étrier.
-
savoir modifier à la volée un formulaire
-
savoir installer Jquery
-
savoir modifier à la volée un formulaire avec Jquery
OUTILS
-
serveur apache+MySQL+PHP local : Wamp
-
éditeur de texte : Notepad++ (ou autre). Ne pas commencer avec un IDE tout de suite (ex Netbeans) qui sont très utiles mais ajoutent une couche technique supplémentaire à comprendre. Important, votre éditeur de texte peut travailler avec plusieurs encodages.
-
firefox : installer le module Firebug (très important pour le CSS+HTML+javascript)
-
firefox : installer le module Web Developer http://chrispederick.com/work/web-developer/ (très important pour le CSS+HTML+javascript)
Divers
-
se documenter sur les sujets traitants de la navigabilité, l'usabilité, la sémantique CSS
-
essayez de gérer le multilingue dès le début dans vos travaux. C'est complexe mais très formateur.
-
Become frustrated when Django (even with the available add-on libraries) doesn't fit your intended type of site exactly (you aren't building a CMS, after all), and decide to try some other frameworks.
-
Decide that none of the other frameworks (even the ones that fit your intended use better) are well enough supported / a good enough fit / small enough to understand, so you decide to create your own framework that does exactly what you need.
-
Realize, after maintaining your own framework for a while, that hey, maybe you could release it as open source to spread the maintenance burden around a bit[2].
-
You know, maintaining an open source project is kinda hard work, and you're not really getting a lot of help, just complaints about missing documentation.
-
Realize that for the same effort, you could have been adding documentation or 3rd-party libraries for an existing framework and you could have had the best of both worlds. Pick the Pyramid [3] framework as the project to merge with/switch to/join because it leaves you with the greatest degree of freedom.
-
Occasionally still build a site with Django, because after all, the CMS-like use cases it is designed for are actually pretty common, and it does have a large and active community.
[1] At one point, the answer here would have been Zope or Plone
[2] Notice how #5 contributes to the problem in #1.
[3] Depending on your actual use-case, your answer here might be very different such as Flask (Python framework), Twisted, Tornado , or any number of other Python Web Frameworks each with it's own sweet spot.
I
happen to have just done this - learned Python for the sake of
developing a Web browser-driven interface to a system.
I learned Python from scratch and developed the core of my system in the space of four afternoons, so this is definitely possible, as Python is really a wonderful language.
I agree with the first poster (Luis M. Gonzalez), excepting that
Javascript is not necessary unless you plan to use in browser
functionality. For me the best learning curve has been (I already know HTML and CSS, so starting after that):
1. Write the program as a CGI script (google this if you don't know what it is). While this is technically the worst way to write a Web program (it's slow, often insecure, and you have to reinvent the wheel a lot), it is conceptually the easiest to understand and gives you the chance to learn how Python actually works, as well as a direct interface with the browser.
2. Upgrade your script to use a microframework - like Bottle.py or Flask. It is relatively easy to convert a CGI script in this way, while you would have to start from scratch to use a full framework like Django. Also use a templating engine (like Mako or Jinja2).
3. Finally, if you find that you are developing a big and complex system, use Django. It seems like a really bad idea to me to go straight to using Django since you will not get a chance to develop your Python or Web scripting skills.
I learned Python from scratch and developed the core of my system in the space of four afternoons, so this is definitely possible, as Python is really a wonderful language.
I agree with the first poster (Luis M. Gonzalez), excepting that
Javascript is not necessary unless you plan to use in browser
functionality. For me the best learning curve has been (I already know HTML and CSS, so starting after that):
1. Write the program as a CGI script (google this if you don't know what it is). While this is technically the worst way to write a Web program (it's slow, often insecure, and you have to reinvent the wheel a lot), it is conceptually the easiest to understand and gives you the chance to learn how Python actually works, as well as a direct interface with the browser.
2. Upgrade your script to use a microframework - like Bottle.py or Flask. It is relatively easy to convert a CGI script in this way, while you would have to start from scratch to use a full framework like Django. Also use a templating engine (like Mako or Jinja2).
3. Finally, if you find that you are developing a big and complex system, use Django. It seems like a really bad idea to me to go straight to using Django since you will not get a chance to develop your Python or Web scripting skills.
There
are 3 steps in the process.
1. You learn about programming , language syntax and features, basics of http protocol, how a web server works and how to exchange data between client and server. Read here The Python Tutorial , this Web Development Course Online - How To Build A Blog - Udacity course is really good one. When I took it, it was free. You can read about http protocol and data exchange hereHTTP Overview
2. You learn about frameworks like Django that enable you to exchange data between webserver and browser and handle data on server side using python. When I started, I liked Django - it taught me MVC (Model-View-Controller) design pattern. However once I got smooth with Web-dev as such, I found Django to become a bottle neck. It puts a lot of restrictions on how and what I should be using. That's when I started learning about other things and got into using specific framework for each role and use it in more flexible ways.
Webserver: TornadoWeb, webapp2, web2py, cherrypy
Template Engine: Jinja2
Database: SQLite / MySQL | [NoSQL] Redis / CouchDB / MongoDB
Django integrates all 3 above together and gives you out of box solution. A very good thing for a beginner. But once you get better, you may or may not want to stick to it.
3. After feeling really good that you are able to do step 1 and 2, get frustrated that the site you made is still running locally on your computer. This is the time you get into dirty details of how to make your website publicly available. Running your own server behind a static ip address is costly and inefficient (unless your audience are going to be people on a LAN). Then you look for various web hosting offerings - tonnes of them and get bogged down with which one to go for. Oh that one gives a good price but doesn't allow me to run my applications. Oh this one allows me to run applications but is too costly. And look this another one lets me run my app and is cheap but doesn't give me full access. And lot more such messed up things you will waste time on. But eventually you need to make a choice.
So far I have tried BigRock, Google App Engine, Heruko, Redhat Openshift and compared a hell lot of hosting plans and services. Of everything, I have found AWS really promising in long run while Redhat Openshift is really good to get started with in a flexible way for small websites (because of its free plan). Google App Engine is easy to onboard but then you get locked in with google's technology and syntax. Makes it difficult to migrate your website later in time. Other hosting plans fell into not enough features or too costly for features I wanted. I have a written a blog on how to get started with a simple out of the box website with Redhat Openshift. In case you are interested, read here Get your own Free website using Red Hat Openshift | Anshul's Galaxy
1. You learn about programming , language syntax and features, basics of http protocol, how a web server works and how to exchange data between client and server. Read here The Python Tutorial , this Web Development Course Online - How To Build A Blog - Udacity course is really good one. When I took it, it was free. You can read about http protocol and data exchange hereHTTP Overview
2. You learn about frameworks like Django that enable you to exchange data between webserver and browser and handle data on server side using python. When I started, I liked Django - it taught me MVC (Model-View-Controller) design pattern. However once I got smooth with Web-dev as such, I found Django to become a bottle neck. It puts a lot of restrictions on how and what I should be using. That's when I started learning about other things and got into using specific framework for each role and use it in more flexible ways.
Webserver: TornadoWeb, webapp2, web2py, cherrypy
Template Engine: Jinja2
Database: SQLite / MySQL | [NoSQL] Redis / CouchDB / MongoDB
Django integrates all 3 above together and gives you out of box solution. A very good thing for a beginner. But once you get better, you may or may not want to stick to it.
3. After feeling really good that you are able to do step 1 and 2, get frustrated that the site you made is still running locally on your computer. This is the time you get into dirty details of how to make your website publicly available. Running your own server behind a static ip address is costly and inefficient (unless your audience are going to be people on a LAN). Then you look for various web hosting offerings - tonnes of them and get bogged down with which one to go for. Oh that one gives a good price but doesn't allow me to run my applications. Oh this one allows me to run applications but is too costly. And look this another one lets me run my app and is cheap but doesn't give me full access. And lot more such messed up things you will waste time on. But eventually you need to make a choice.
So far I have tried BigRock, Google App Engine, Heruko, Redhat Openshift and compared a hell lot of hosting plans and services. Of everything, I have found AWS really promising in long run while Redhat Openshift is really good to get started with in a flexible way for small websites (because of its free plan). Google App Engine is easy to onboard but then you get locked in with google's technology and syntax. Makes it difficult to migrate your website later in time. Other hosting plans fell into not enough features or too costly for features I wanted. I have a written a blog on how to get started with a simple out of the box website with Redhat Openshift. In case you are interested, read here Get your own Free website using Red Hat Openshift | Anshul's Galaxy
There
are many ways to create websites using Python. The first question you
might want to ask is: "How big is this website project?" In
other words, "What do I want this website to do?"
One of the first things to learn in this case is the Model-View-Controller (MVC) framework system. I won't go into details here, but essentially the model represents your data storage (i.e. back-end), the view controls your user interaction (i.e. front-end), and the controller(s) help communicate between the two. Usually (and I stress usually), a python-based framework will have the views comprise of HTML, javascript, and CSS; the controllers will be python files; and the model, if it is even necessary, will be some sort of SQL server. Different frameworks (e.g. django, pylons, pyramid, cherrypy, flask) will accomplish the MVC framework differently. I suggest using the links in the other comments to get a tutorial headstart.
To answer your postscript, see the following:
- brew: (Homebrew?) a package manager that helps with installations
- pip: more packaging and installation funsies
- virtualenv: helps to contain your project within a (get this) virtual environment. Basically, if you run a run a script that messes up your installation of python or anything else, at least you don't mess it up for your whole computer -- just in that partition.
- django: the name of the python-based framework I'm assuming you are using to create the website.
- eclipse: the text editor (used in conjunction with Pydev) so you can actually edit your code. A lot of the time, you're probably going to run stuff from your Terminal, so other text editors could be useful as well (e.g. TextWrangler, Coda2)
One of the first things to learn in this case is the Model-View-Controller (MVC) framework system. I won't go into details here, but essentially the model represents your data storage (i.e. back-end), the view controls your user interaction (i.e. front-end), and the controller(s) help communicate between the two. Usually (and I stress usually), a python-based framework will have the views comprise of HTML, javascript, and CSS; the controllers will be python files; and the model, if it is even necessary, will be some sort of SQL server. Different frameworks (e.g. django, pylons, pyramid, cherrypy, flask) will accomplish the MVC framework differently. I suggest using the links in the other comments to get a tutorial headstart.
To answer your postscript, see the following:
- brew: (Homebrew?) a package manager that helps with installations
- pip: more packaging and installation funsies
- virtualenv: helps to contain your project within a (get this) virtual environment. Basically, if you run a run a script that messes up your installation of python or anything else, at least you don't mess it up for your whole computer -- just in that partition.
- django: the name of the python-based framework I'm assuming you are using to create the website.
- eclipse: the text editor (used in conjunction with Pydev) so you can actually edit your code. A lot of the time, you're probably going to run stuff from your Terminal, so other text editors could be useful as well (e.g. TextWrangler, Coda2)
Aucun commentaire:
Enregistrer un commentaire