How do I start learn Python for web [closed] - python

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I have been learning Python for a while, and now I'd like to learn Python for the web; using Python as a back-end of a website. Where and how do I start learning this?
Example usages are: connecting to databases, and retrieving and storing information from forms.

While using a full framework like Django, Pylons or TurboGears is nice, you could also check out the more light-weight approaches.
For instance:
Werkzeug: http://werkzeug.pocoo.org/documentation/dev/tutorial.html
web.py: http://webpy.org/
Bottle: http://bottle.paws.de/

You should check out Django, which is the most popular python web framework. It has a lot of features, such as an ORM and a template language, but it's pretty easy to get started and can be very simple to use.

You might also try:
Tornado, which allows you to write pure python right into templates.
web2py is a good start as it doesn't requires installation or configuration,and has no dependencies, it's pretty simple to learn
and use.
Another good option if you wanted to speed the learning process would be take a customized crash course in python with an expert. As an example: https://www.hartmannsoftware.com/Training/Python?

There are numerous frameworks for making websites in Python. Once you are familiar with Python and the general nature of websites which would include the knowledge of HTTP, HTML you can proceed by using any of the following to make websites using Python:
Webapp2 - A simple framework to get you started with making websites and using this framework you can easily make websites and cloud services and host them on the Google App Engine service. Follow these links for more information on use and hosting: Welcome to webapp2!, Google App Engine
Django - As Alex Remedios has mentioned Django is also a very popular and widely used MVC web framework for Python. It is very comprehensive and follows the MVC web design principles. Various hosting options are also available for the same. You can learn more about Django here - The Web framework for perfectionists with deadlines, The Django Book (for learning the use of Django)
Flask - Flask is a simplistic framework for making webapplications and websites using Python. I do not extensive experience using it but from what I have read it is similar to Webapp2 in many ways but is not as comprehensive as Django. But, it is very easy to pickup and use. Flask (A Python Microframework)
As far as my knowledge goes these are the best ways to use Python in the web. To answer your second question, it is not implicitly possible to use Python in cohesion with HTML content like you would with PHP. However, there are libraries to do that too like the following:
Python Wiki - Digi Developer
Karrigell 3.1.1
If you are making extensive applications/websites the above two frameworks will pose major problems in doing simple tasks.

there are numerous options for learning python for web. I learned python to access web data from courser.org, and the tutorial was very interesting. If you want to learn python for web then I suggest you to learn python to access web data in courser.org
you can also learn python for everybody which is a specialization course with 5 courses in which each and every thing about python is given.
The fun part of courser.org is that they provide assignments with due dates which means you have to complete an assessment of each week in that week itself. They also provide quiz. You have to pass all the assignments and quizzes to get the certificate which is very easy, you can easily complete the assessment and quizzes.

Related

Alternatives to Django for Python based Web Development? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I am about to start a new personal web / iphone app project which requries the following:
Storing data on the backend
authenticating the user via openid
Generate JSON based APIs for reading and writing data
I normally use Django for all of my projects but thought I would take this opportunity to learn something new. So, are their any Python based web development frameworks that are good alternatives to Django? Ideally ones that are strong on the points listed above?
Bonus points if the framework is:
lightweight
easy to install, deploy and developwith
Any recommendations?
I've only ever used Django and I love it, but here's a couple others (I think Flask is your best bet for a very small and very lightweight web app)
Flask
"Flask is a microframework for Python based on Werkzeug, Jinja 2 and good intentions."
- http://flask.pocoo.org/
Pylons
"Rather than focusing on a single web framework, the Pylons Project will develop a collection of related technologies. The first package from the Pylons Project was the Pyramid web framework. Other packages have been added to the collection over time, including higher-level components and applications. We hope to evolve the project into an ecosystem of well-tested, well-documented components which interoperate easily." - http://www.pylonsproject.org/
Grok
"Grok is a web application framework for Python developers. It is aimed at both beginners and very experienced web developers. Grok has an emphasis on agile development. Grok is easy and powerful." - http://grok.zope.org/
TurboGears
"TurboGears will help you to create a database-driven, ready-to-extend application in minutes. All with code that is as natural as writing a function, designer friendly templates, easy AJAX on the browser side and on the server side and with an incredibly powerful and flexible Object Relational Mapper (ORM)." - http://www.turbogears.org/
More Python Framework Resources
After a little more digging I found this resource: http://wiki.python.org/moin/WebFrameworks/
I've used web2py for a couple small projects and really liked it.
It is pretty lightweight, has great documentation, and in my experience very simple to deploy.
I've never used Django, so I'm not sure how it compares.
A few hello worlds:
def hello1():
return "Hello World"
def hello5():
return HTML(BODY(H1(T('Hello World'),_style="color: red;"))).xml() # .xml to serialize
def hello3():
return dict(message=T("Hello World"))
The corresponding view for hello3:
{{extend 'layout.html'}}
<h1>{{=message}}</h1>
Use web.py can be found at http://webpy.org/ Very simple URL handling and lots of built in functionality but still light weight

Will learning Django translates well into other applications?

Does anyone have experience using Python in different variaty of applications?
A little background - I am a 3D artist in an animation studio. I do programming in PHP and use Zend framework for my personal project. Python has always been a language I wanted to learn because it can be used within many applications our studio is using (3D MAX, MAYA to name a few) My supervisor knew about my web background and wanted me to create a web base time line manager for the company. From the requirement I'm expecting quite a simple backend ... so it might be a good opportunity to finally learn Python. The bulk of the work will be on AJAX for the interactive front end.
So if I learn Python with web application and Django in mind, will that limit my Python skill from applying it to other applications?
a little curious about Django features as well. How well does the framework cover in terms of web application compare to Zend? Our application is pretty basic in the back end and I would love to know if Django will be able to cover them.
authenticate against Windows active directory
quick database update via AJAX interaction (drag and drop time line mostly)
Other basic stuff like discussion forum and directory browsing/file manager
So if I learn Python with web application and Django in mind, will that limit my Python skill from applying it to other applications?
No
authenticate against Windows active directory
Yes. You may need to customize an Authentication Backend.
quick database update via AJAX interaction (drag and drop time line mostly)
Django has nothing to do with Ajax. Use piston to create pleasant RESTful API that Ajax can use.
Other basic stuff like discussion forum and directory browsing/file manager
There are many, many canned applications for Django that you can plug in and integrate.
I love python as a language - but it's not the answer to everything. I know this is throwing mud in a python group, but python has one serious limitation - the rigid source code format.
While going through a django tutorial - I noticed that you cannot insert python source code into a template, and that this was presented as a 'feature' for separating programmers and designers.
I later realized that it's a limitation of django - and any other environment where python source code might get accidentally mangled. This also includes HTML WYSIWIG editors and database based 'manglers' (like Drupal).
In my opinion it's a very serious limitation with no easy cure - especially with the need to use other tools to manage the complexity of HTML / CSS / JavaScript.
I found Django a really good way to learn python. There's very little that's quirky, magical or un-pythonic in the framework. A bit of setup and you're away, writing standard python code.

Good resources to start python for web development?

I'm really interested in learning Python for web development. Can anyone point me in the right direction? I've been looking at stuff on Google, but haven't really found anything that shows proper documentation and how to get started. Any recommended frameworks? Tutorials?
I've been doing PHP for 5 years now, so I just want to try something new.
Django is probably the best starting point. It's got great documentation and an easy tutorial (at http://djangoproject.com/) and a free online book too (http://www.djangobook.com/).
Web Server Gateway Interface
About
http://www.wsgi.org/en/latest/index.html
http://en.wikipedia.org/wiki/Web_Server_Gateway_Interface
Tutorials
http://webpython.codepoint.net/wsgi_tutorial
http://lucumr.pocoo.org/2007/5/21/getting-started-with-wsgi/
http://archimedeanco.com/wsgi-tutorial/
There are three major parts to python web frameworks, in my experience. From the front to back:
Views/Templates: Application frameworks don't function as independent scripts - instead, you map paths to python functions or objects which return html. To generate the html you probably need templates (aka views). Check out Cheetah.
Application framework/Server: There are plenty. CherryPy is my favorite, and is good for understanding how a python application server works because a) it's simple and b) unlike django and others, it is just the application server and doesn't include a templating engine or a database abstraction layer.
Database layer: I've actually never used it, but everyone seems to like SQLAlchemy. I prefer, in simple applications, executing SQL directly using a tool like psycopg2 (for postgres).
You can try Django. It's easy to learn, and it works with GAE (though the default version is 0.96, a little bit old, but you can change it). And there's a video about rapid development (by Guido Van Rossum) that goes through the basics of setting up a Django project in App Engine.

How to create simple web site with Python? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 1 year ago.
Improve this question
How to create simple web site with Python?
I mean really simple, f.ex, you see text "Hello World", and there are button "submit", which onClick will show AJAX box "submit successful".
I want to start develop some stuff with Python, and I don't know where to start.
I was hoping more elaborate answers would be given to this question, since it's a sensitive subject. Python web developing is split across lots of frameworks, each with its ups and downs and every developer using a different one. This is quite unfortunate. What you should know:
Use WSGI. Don't use anything else, WSGI is the latest standard in Python web developing;
Don't develop directly on top of WSGI, unless you really have to (not even for a hello world app);
Use a framework that best suits your needs:
I played with Werkzeug (which is not really a platform, they call it a toolkit) because it's really simple yet powerful. It lets you work on the WSGI level (also helps you understand how WSGI works) while providing really useful features and helpers. On the Werkzeug website you will also find useful tutorials and things like that.
Probably the most popular framework is Django. Never used it, but maybe there's a reason for why it is so popular.
In conclusion, use whatever is closest to your heart.
You can write a web site with Python in which the web server is implemented in Python, or in which Python is called from some other web server. If you do not already have a web server set up, the first option is easier. The Python library includes a fully functional web server, all you have to is add a couple of methods to respond to requests.
For a complete example of a web site using this simple technique, see Making a simple web server in Python
This technique may or may not serve you well for developing commercial, production web sites, but it's the simplest way from P(ython) to W(ebsite).
Why don't you try out the Google AppEngine stuff? They give you a local environment (that runs on your local system) for developing the application. They have nice, easy intro material for getting the site up and running - your "hello, world" example will be trivial to implement.
From there on, you can either go with some other framework (using what you have learnt, as the vanilla AppEngine stuff is pretty standard for simple python web frameworks) or carry on with the other stuff Google provides (like hosting your app for you...)
As Felix suggested, definitely use WSGI (mod_wsgi) as your gateway interface. It is the modern way of doing business and the other major contendor, mod_python, is no longer being maintained.
Django is a great choice if you want a full-fledged production-quality framework but it also comes at the cost of having a lot of overhead and a pretty steep learning curve.
My suggestion is: Tornado!
I have found that Tornado makes it very easy to get up and running quickly. To illustrate here is the "Hello, World" from the Tornado documentation:
import tornado.httpserver
import tornado.ioloop
import tornado.web
class MainHandler(tornado.web.RequestHandler):
def get(self):
self.write("Hello, world")
application = tornado.web.Application([
(r"/", MainHandler),
])
if __name__ == "__main__":
http_server = tornado.httpserver.HTTPServer(application)
http_server.listen(8888)
tornado.ioloop.IOLoop.instance().start()
In my opinion that speaks for itself.
Edit: It's important to note that you don't have to use the web server that comes with Tornado. It plugs very easily into WSGI to run with whatever server you already have going.
Best of luck in your search!
You can take this course offered FREE on udacity Web Development using Python.
This is great course and teaches from scratch using GAE. At the end of the course you would have a full fledged blog of yours on web developed by you in python.
P.S one of the instructor is Steve Huffman founder of Reddit.
I think you should start with some kind of Python web framework. For me Web2Py is both easy and powerful. Of course you can create your pages using CGI: no framework required, but for more complicated sites it is not practical.

What is a good reference for Server side development?

I am more interested in the design of the code (i.e functional design vs object oriented design). What are the best practices and what is the communities thoughts on this subject?
Not that it should matter, but I am working with Apache and Python technology stack.
If you are using Apache+Python, this sounds like you are using Python for dynamic web pages. In that case, I would strongly urge you to look into Django. There are also other Python web development environments, but Django is perhaps the most popular; and it has excellent documentation such as The Django Book. The Django Book describes best practices for setting up a robust web site: how to use multiple servers for redundancy, how to set up the database server, how to set up a cache to reduce the load on your database, etc.
Other than that tip, good Python server-side code would be just good Python code. There was a question asked recently about how to become a good Python developer, and I would suggest you read that: How do I get fluent in Python?

Categories

Resources