Sunday, January 10, 2016

Getting started with web2py framework



    Full Stack web development with Python (Web2Py)
    How to download and install web2py
1.  Go  to http://web2py.com/
2.   Down load latest version http://web2py.com/init/default/download
     Unzip the downloaded file
     CliCk on the Web2py.exe file to it will open the window like below





           Provide the password(any password) and start the server
           Server has been started. Now we need to create a application using web2py framework.
           http://localhost:8000

                                                

         Click on the Admin,  which is there on the right side in the page. And provide the password which      we have given while starting the server





                After Successful Login,  page will be open like below.

               Create a new application using this framework- > New simple application –
       Application Name - ex: sivaweb2py
              Click on the create button. Now we have created application successfully.
               Need to run the application
               http://localhost:8000/sivaweb2py
               


              Now we need to write sample code in this application. So we need to understand basics of  the
       framework
               Need to edit the application


      This framework will follow MVC architecture
          Model- Contains db details
         Controller – Method and logic details
         Views – Html input/output to the user

Now we need to create one controller and respective views
Click on the Create button under Controller Section
I have given controller name as basics – basics.py will be created under controller

       Now edit the controller – Click on the basics.py
     def helloworld():
     msg= "Hello welcome to basics controller!"
     return locals()


 In the above code helloworld is method name . Copy the code and paste the same in your file.
  Save the file and go to back – by click on the back buton
  Now we need to create a  view- under Views section
  View name should be as method name  ex: basics/helloworld

   {{extend 'layout.html'}}
    This is our first web page
   {{ =msg}}

Writing first web2py is very easy


                          

        

                               






No comments:

Post a Comment

AddToAny

Contact Form

Name

Email *

Message *