Introduction:
Flask is a micro web framework written in python. It is well known as a lightweight framework for python web development because it is run on a stand-alone file whereas Django has multiple files for each operation such as URLs, views, and setting.
How to install flask using pip3
pip3 install flask
What you will learn from this post:what you:
- What is flask
- how to install flask
- static routes in flask
- dynamic routes in flask
- define function in flask
How to run this file
- open terminal/cmd type “python3 first_app.py”
- open “http://127.0.0.1/5000” (port may be vary)
# here I import flask library from flask import Flask app=Flask(__name__)#this is stattic route ,here i set index function on my landing page @app.route('/') def index(): return "<h1>Hello ,this is a landing page</h1>" #return method display this string in our landing page#this is also static route, now i set "http://127.0.0.1:5000/about" to page function. @app.route('/about') def page(): return "<h1>This is about page</h1>" # again return method display this string in our abour page# here i used dynamic route (this type of route uses in page per user websites) #<name> is dynamically change as per user input #ttp://127.0.0.1:5000/user/rajat @app.route('/user/<name>') def users(name): return "<h1>User name is : {}</h1>".format(name) #here return display dynamic result with the help of string formating if __name__=="__main__": app.run(debug=True) #app.run execute program and I enabled debug because this mode helps up catch errors.
Some truly nice and utilitarian information on this site,
also I believe the pattern has got superb features. https://www.bubookids.com/blogs/reviews/kidkraft-shimmer-mansion-dollhouse-review
LikeLiked by 1 person
I’ve read a few just right stuff here. Definitely worth bookmarking
for revisiting. I surprise how so much effort you set to create this
sort of magnificent informative website.
LikeLiked by 1 person
Informative article, just what I needed.
LikeLiked by 1 person
It’s difficult to find knowledgeable people for this topic, but you seem
like you know what you’re talking about! Thanks
LikeLiked by 1 person
Thanks for some other informative site. Where else could I get that kind of info written in such a perfect method?
I’ve a challenge that I am just now operating on, and I’ve been on the glance out for such info.
LikeLike
Thanks Adam,
For python stuff please pay a visit on my github profile
https://github.com/rajat4665
LikeLike
It’s in reality a nice and helpful piece of info.
I am happy that you just shared this helpful info with
us. Please stay us informed like this. Thanks for sharing.
LikeLiked by 1 person
Thanks @renovasi otak
LikeLike
Well, the blog is very interesting because it has many things about technology and is one of those that contain the latest trends and it is seen that they really want to make a change in the world. Thanks for sharing!!!
LikeLike
Absolutely worth bookmarking
for revisiting. I wonder how so much struggle you set to create this
sort of outstanding informative website.
LikeLike
This blog is very interesting because it has many things about technology and is one of those that contain the latest trends and it is seen that they really want to make a change in the world
LikeLike
If you are going for most excellent contents like myself, just go to see this website all the time because it gives quality contents, thanks
LikeLike