User:Ndhanir: Difference between revisions

From Expertiza_Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 16: Line 16:
Web.py is a [[free and open source]] [[Web application framework]] that is as simple as it is powerful.
Web.py is a [[free and open source]] [[Web application framework]] that is as simple as it is powerful.


The web.py slogan is: "Think about the ideal way to write a web app. Write the code to make it happen."[http://webpy.org/]. The goal of web.py is to build the ideal way to make web apps. Web.py allows the user to build [[HTTP]] responses instead of exposing [[Python]]] objects. Web.py allows the user to access the [[database]] easily without making the database look like an object. Also, the web.py template system tries to bring Python into [[HTML]][http://webpy.org/philosophy]. "It's the anti-framework framework. web.py doesn't get in your way." explained founder Steve Huffman.
The web.py slogan is: "Think about the ideal way to write a web app. Write the code to make it happen."<ref>{{Cite web|title = Linking to another record|url = http://webpy.org/|website = web.py|access-date = 2016-02-06}}</ref>[http://webpy.org/]. The goal of web.py is to build the ideal way to make web apps. Web.py allows the user to build [[HTTP]] responses instead of exposing [[Python]]] objects. Web.py allows the user to access the [[database]] easily without making the database look like an object. Also, the web.py template system tries to bring Python into [[HTML]][http://webpy.org/philosophy]. "It's the anti-framework framework. web.py doesn't get in your way." explained founder Steve Huffman.


Some of the [https://en.wikipedia.org/wiki/Website websites] which uses web.py are
Some of the [https://en.wikipedia.org/wiki/Website websites] which uses web.py are

Revision as of 22:06, 15 February 2016

Template:Infobox software


Web.py is a free and open source Web application framework that is as simple as it is powerful.

The web.py slogan is: "Think about the ideal way to write a web app. Write the code to make it happen."<ref></ref>[1]. The goal of web.py is to build the ideal way to make web apps. Web.py allows the user to build HTTP responses instead of exposing Python] objects. Web.py allows the user to access the database easily without making the database look like an object. Also, the web.py template system tries to bring Python into HTML[2]. "It's the anti-framework framework. web.py doesn't get in your way." explained founder Steve Huffman.

Some of the websites which uses web.py are

  • Frinki, a new social network in spanish.
  • oyster.com, a website that reviews hotels uses web.py for the entire website.
  • Make History, a project of the 9/11 memorial museum.

History

Web.py was originally published while Aaron swartz worked at reddit.com, where the site used it as it grew to become one of the top 1000 sites according to Alexa and served millions of daily page views. The site was rewritten using other tools after being acquired by Condé Nast. [3]

Python

Python is a multi-paradigm programming language: object-oriented programming and structured programming are fully supported, and there are a number of language features which support functional programming and aspect-oriented programming (including by metaprogramming). Python uses dynamic typing and a combination of reference counting and a cycle-detecting garbage collector for memory management. An important feature of Python is dynamic name resolution, which binds method and variable names during program execution.

Ruby's creator, Yukihiro Matsumoto, has said: "I wanted a scripting language that was more powerful than Perl, and more object-oriented than Python. That's why I decided to design my own language."

The world of Python web frameworks is full of choices. Django, Flask, Pyramid, Tornado, Bottle, Diesel, Pecan, Falcon, web.py, web2py and many more are competing for developer mindshare. The developer needs to cut the options down to one framework depending on the type of application.

Why Web.py?

The reasons for using web.py are

  • Simplicity
  • Freedom
  • Writing clean code
  • Minimalism
  • A solid web framework

Installation

To install web.py,

  • Firstly, download the following tar file:
wget http://webpy.org/static/web.py-0.37.tar.gz
  • Extract the downloaded tar file:
tar -zxvf web.py-0.37.tar.gz
  • Go to web.py-0.37 directory:
cd web.py-0.37/
  • Install and make it accessible to all the applications:
sudo python setup.py install

Web.py skeleton

Every web application needs a skeleton. A sample skeleton of web.py application looks as follows.[4]

  • doc: Documentation of all the files.
  • licenses: All the licenses of the project and the libraries used in the application.
  • requirements: Specifying the third party libraries.
  • sh: bash script files of the project.
  • www: The required web application itself.
    • app: contains the application modules.
      • controllers: This module contains the handler modules of controller package.
      • tools: Tools that are used for the project.
      • views]: Template files.
      • models: Database models of the application.
      • bridge: It is used to communicate with the server which is written in another language.
    • lib: The library files developed for the project. These are different from the tools mentioned in the app. Libraries can be used in other projects where as tools are limited to the project itself.
    • public: This folder contains the minimized compiled CSS, Javascript, CoffeeScript files and images so the files in this folder are production ready and can't be used in development.
    • static: Contains the development CSS, CoffeeScript, Javascript, and images files of the project.
    • test: As you can guess easily, these are the test files.
    • tmp: Garbage files.
    • main.py: These are the only files that are directly executed by the server.
    • main_development.py: Main executable file in development mode.
    • settings.py: Global constants and settings of the application.
    • urls.py: Contains URL's of the application

Features of web.py

web.py has two unique features

Databases

The database package lets the user access different databases. Accessing different databases refers to connecting to multiple databases. However, its not an ORM. The databases in ruby benefit the people who are good at SQL and don't like to use ORM. This feature is missing in Django (another web framework based on python). [5]

Forms

A forms package is present in web.py which let's us create forms and validators. The form module of web.py allows the ability to generate html forms, get user input, and validate it before processing it or adding it to a database. But it doesn't have built-in protection against CSRF. A simple login form would look as given below:

login = form.Form(
    form.Textbox('username'),
    form.Password('password'),
    form.Button('Login'),
)

Another feature about web.py is its flexibility. It has flexible modules which can be used with another framework.

Hello world example

import web
urls = (
	'/', 'index'
	)

class index:
	def GET(self):
		return "Hello, ECE517!"

if __name__ == "__main__":
	app = web.application(urls, globals())
	app.run()

[6]

Consider the given example, the user start the application by importing the web.py module using the following command

import web

The most important part of the website is its URL structure. web.py makes it easy to make great URLs.

urls = (
  '/', 'index'
)

The first part is a [https://en.wikipedia.org/wiki/Regular_epython/posts/django-flask-pyramid

[5] Form Validation: https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Forms/Data_form_validation

[6] Aaron swartz about web.py http://www.aaronsw.com/weblog/rewritingreddit

[7] https://www.wikipedia.org/