Thursday 18 August 2016

python first webapp program

1 - create folder : mkdir myfirstapp
2-  pip install lpthw.web (install commond)
3 . create init file ( touch __init__.py)
4. create app file
    vim app.py
import web

urls = (
  '/', 'index'
)

app = web.application(urls, globals())

class index:
    def GET(self):
        greeting = "Hello World"
        return greeting

if __name__ == "__main__":
    app.run()


5 - save file and run
python app.py


open webbrowser
put on url :-localhost:8080
Output :-
Hello World


   

No comments:

Post a Comment