Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / NewStats: 3,195,355 members, 7,957,955 topics. Date: Wednesday, 25 September 2024 at 05:45 AM |
Nairaland Forum / Science/Technology / Programming / Web Programming Tutorial In Python. (4466 Views)
Web-designing Tutorial In Ibadan / Who Wants To Learn Programming In Python Easily Without Stress? READ THIS / Loki v 1.8 http Bot | Best Botnet 2017| Programming Tutorial |all Browser (2) (3) (4)
Web Programming Tutorial In Python. by webstacka: 11:07pm On Jul 27, 2017 |
No much introduction. I'm a bit free so I decided to do this tutorial before I get busy again. Hope someone learns something from this tutorial. The tutorial is about web programming in python using a micro web framework called bottle. Python bottle is a minimalistic and fast web framework used for developing simple REST services. However, nothing stops you from developing a full-fledged web application with python bottle. One good thing, or maybe a con, of bottle is its single file approach. Bottle is a single python file that requires no external library order than the python standard library. However, this approach makes it a bit difficult to integrate it with other modules, but this can be solved by building your web application with object-orientation in mind from scratch. REQUIREMENTS: 1) Python 3.4 + 2) Bottle web framework (pip install bottle) with internet connection. 3) Web server (optional). Bottle can run with python's standard wsgiref server bundled with python. However, we need a faster web server that will make our development easier. Popular wsgi-based web servers for python are cherrypy, rocket, twisted, tornado, gunicorn, paste, etc. Since we're just using it for development, our best bet would be python paste or cherrypy. I'll use paste (pip install paste) and that's it! 4) text editor. Any good text editor is okay by me, except notepad. Well, I use notepad++ That is all we need for now. Let's get started! |
Re: Web Programming Tutorial In Python. by 4kings: 11:12pm On Jul 27, 2017 |
Thank you, the section will be a little bit revived. Following. CC dhtml18 silento pcguru1 BinaryMonk and co |
Re: Web Programming Tutorial In Python. by adepeter2027(m): 11:13pm On Jul 27, 2017 |
Following 1 Like |
Re: Web Programming Tutorial In Python. by edicied: 11:17pm On Jul 27, 2017 |
adepeter2027:did you study comp sci? |
Re: Web Programming Tutorial In Python. by adepeter2027(m): 11:19pm On Jul 27, 2017 |
Re: Web Programming Tutorial In Python. by Muhammedbashir(m): 11:20pm On Jul 27, 2017 |
interested |
Re: Web Programming Tutorial In Python. by edicied: 11:26pm On Jul 27, 2017 |
adepeter2027:wow nice everyone should learn how to code |
Re: Web Programming Tutorial In Python. by adepeter2027(m): 11:27pm On Jul 27, 2017 |
edicied:But you know this state-of-the-art yours is impossible. Not everybody loves CMP related stuffs. Abeg, make i no derail this thread. Op, apologies |
Re: Web Programming Tutorial In Python. by webstacka: 11:32pm On Jul 27, 2017 |
Now let us do the needful in programming, that is, creating the mandatory hello world app in bottle. First open a text editor and create a python file called lesson.py, and save it in a folder under your C: \ drive, called BottleApp (make sure its created, if not then create it too). Next, edit the lesson.py with the following source code:
Now save it. Open a command prompt or unix shell, navigate to where you saved the file, i.e, cd C: \BottleApp Type the following on the command prompt: python -m lesson Hit enter. Open a web browser and navigate to 127.0.0.1:8080/ You will see your app running... 1 Like |
Re: Web Programming Tutorial In Python. by webstacka: 12:09am On Jul 28, 2017 |
Checking time let us use python's datetime library to know the time. This will demonstrate how to use string interpolation in python. But before then, let me introduce a python module that is handful when starting a web browser. It is called the webbrowser module. I'll show how it works in the example below:
1 Like |
Re: Web Programming Tutorial In Python. by webstacka: 12:26am On Jul 28, 2017 |
Creating multiple functions Functions are the building blocks of any programming language. We have already seen a function, that is, the index function wrapped with a decorator. We will later see how python decorators are built. Creating multiple functions is easy in bottle provided they are wrapped with the same decorator. Let us create some:
This demonstrates the power of python functions, decorator and routing functions in separating concerns. If you have not observed already, bottle follows a strict MVC design pattern; which is a good OOD principle. 1 Like |
Re: Web Programming Tutorial In Python. by webstacka: 12:41am On Jul 28, 2017 |
You may ask questions where you don't understand... |
Re: Web Programming Tutorial In Python. by seunny4lif(m): 5:21am On Jul 28, 2017 |
I'm using Linux not Windows I want to learn Phyton |
Re: Web Programming Tutorial In Python. by webstacka: 6:12am On Jul 28, 2017 |
seunny4lif:Those python codes run on both windows and unix environment, including linux. |
Re: Web Programming Tutorial In Python. by seunny4lif(m): 7:34am On Jul 28, 2017 |
webstacka:I'm a beginner in Python programming I know Java but not GUI sha and I want to add python then straight to Mobile app becos I like app What do you think ? |
Re: Web Programming Tutorial In Python. by webstacka: 8:45am On Jul 28, 2017 |
seunny4lif: just keep learning python, you will soon master it. Python can be used to create desktop and web application. Also, android and IOS apps can be created with python. |
Re: Web Programming Tutorial In Python. by seunny4lif(m): 9:02am On Jul 28, 2017 |
webstacka:Hope u wouldn't be needing HTML sha Thanks Python look more simple than Java Python is easy to grab unlike Java. |
Re: Web Programming Tutorial In Python. by webstacka: 11:58am On Jul 28, 2017 |
seunny4lif:No. No html... |
Re: Web Programming Tutorial In Python. by silento(m): 12:23pm On Jul 28, 2017 |
python my wife |
Re: Web Programming Tutorial In Python. by seunny4lif(m): 1:00pm On Jul 28, 2017 |
webstacka:Android Application Java and HTLM ? |
Re: Web Programming Tutorial In Python. by webstacka: 4:52pm On Jul 28, 2017 |
seunny4lif: i said you do not need html to develop android apps in python. You need the kivy framework. |
Re: Web Programming Tutorial In Python. by webstacka: 11:47am On Jul 29, 2017 |
Good morning. Like I said before, we are learning python programming using a web application. |
Re: Web Programming Tutorial In Python. by webstacka: 12:04pm On Jul 29, 2017 |
The first you will notice about python is its data types. Python data types are classified into five: 1) integers - negative or positive whole numbers (int) e.g 2, 100, etc. 2) floats - negative or positive decimal points (float) e.g 2.356, -1.846, etc. 3) strings - characters, alphabets and words, enclosed with single or double quotation marks. E.g 'hello', "python bottle", "12*#/", etc. 4) boolean values - true or false statements, denoted by True or False. E.g pay=False, loggedIn=True 5) null values - this is not really a standard data type, but since python is a dynamic language, its data types can change during execution. Thus, a null value is dynamic and its value can change from one data type to another. It is denoted by None. E.g myFruit = None |
Re: Web Programming Tutorial In Python. by webstacka: 12:22pm On Jul 29, 2017 |
Let us see how it works. Now open the lesson.py file and type this in your index function:
the above code shows how to solve simple interest in python. Save it. Run and navigate to localhost:8080/ what do you see? You can see how easy it is to embed python codes in html. |
Re: Web Programming Tutorial In Python. by Snwokenk: 8:39am On Jul 30, 2017 |
Django seems a lot easier and quicker to bring product to market. but will check this out so bottle is a micro framework? people will be better of learning django. its a "batteries included" framework |
Re: Web Programming Tutorial In Python. by melodyogonna(m): 11:19am On Jul 30, 2017 |
Snwokenk:Yeah, but if you need to make a simple webapp or a simple REST services, django might be too bloated for that, i personally recommend that someone should learn a full framework and a micro framework |
Re: Web Programming Tutorial In Python. by webstacka: 12:31pm On Jul 30, 2017 |
Snwokenk: Django is a nice framework, but its not good for teaching beginners web programming. You must have a fair mastery of python to use django. In fact, if you develop an OOD-based web app in bottle, you'll most likely observe that you've developed your own web framework -- and the joy of creating a web framework! |
Re: Web Programming Tutorial In Python. by Nobody: 12:49pm On Jul 30, 2017 |
webstacka: I am planning learning python soon . Is there similarity with bottle micro- framework and flask. |
Re: Web Programming Tutorial In Python. by umaryusuf(m): 3:11pm On Jul 30, 2017 |
proxy20: I was about to ask this question too? |
Re: Web Programming Tutorial In Python. by webstacka: 8:41pm On Jul 30, 2017 |
proxy20: yeah...a lot similar. In fact, bottle is flask without werkzeug. |
Re: Web Programming Tutorial In Python. by Nobody: 9:19am On Jul 31, 2017 |
webstacka:nice 1 Like |
Open Source VTU Portal / Get Link To Download Web Development And Android Complete Tutorials / Oracle 10g On Solaris Os
(Go Up)
Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health religion celebs tv-movies music-radio literature webmasters programming techmarket Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 57 |