what is flask

Solutions on MaxInterview for what is flask by the best coders in the world

showing results for - "what is flask"
Erica
17 Sep 2017
1pip install -U Flask
2
Hester
10 Mar 2018
1from flask import Flask
2
3app = Flask(__name__)
4
5@app.route('/')
6def index():
7  return "Hello world!" #if you want to render a .html file, 
8                        # import render_template from flask and use 
9                        #render_template("index.html") here.
10
11if __name__ == '__main__':
12    app.debug = True
13    app.run() #go to http://localhost:5000/ to view the page.
Liam
04 Feb 2017
1from flask import Flask
2app = Flask(__name__)
3
4@app.route('/')
5def hello_world():
6    return 'Hello, World!'
7
Stephen
07 Jun 2016
1# This is a basic Flask Tutorial
2# First of all, if something doesn't work, you messed up.
3# Too start of, make a project folder and install flask with a venv or just normally.
4# You can install flask with this command: pip install Flask
5# (type this into you're terminal)
6# I f you get an error message, it is because you a, dont have python3 installed,
7# b: youre on a mac that has Python3 and python2 installed (this is probably the case)
8# If you dont have python3 installed then go ahead and install it. If it is case b, then type in
9# pip3 install Flask
10# Now, lets start by making a file named app.py
11# You can return basic html or text when returning in the
12# Hello World function. The @app.route('/') defines that the function
13# Will return at the page '/'. Debug mode is turned on on and the website
14# Will run at 0.0.0.0:5000 aka localhost:5000.
15
16from flask import Flask #Import Flask
17from flask import render_template #Import render template function
18app = Flask(__name__)
19
20
21@app.route('/')
22def hello_world():
23    return '''<h1>Welcome to Flask!</h1><a href=" /about">About Me!</a>'''
24
25
26# You can also return a Template. For that, make a Templates folder
27# and create a file named about.html inside of the Templates folder
28# html file contents (copy and paste it without the hashtags):
29
30#<html>
31#   <body>
32#       <h1>About Me</h1>
33#       <p>Hi, this is me, I am a Python programmer who is currently learning Flask!</p>
34#       <a href="/">Home</a>
35#   </body>
36#</html>
37
38# (You can edit it if you want)
39
40#Just for you info, you your Project folder should look like this:
41#     ProjectFolder:
42#       app.py
43#       Templates:
44#           about.html
45# Lets make a site at localhost:5000/about and use the template we created
46
47
48@app.route('/about')
49def about():
50    return render_template("about.html")  # You can do this with every html file in the templates folder
51
52#If you would like to have the same page with 2 diffrent urls (this works with as many as you want)
53#You can do this:
54@app.route('/page1')
55@app.route('/page2')
56def page1andpage2():
57    return 'Page1 and pag2 are now the same!'
58#ps: you dont have to name the function page1andpage2
59#you can name every function as you like. It doesn't matter.
60#The only thing that matters about the url is the decorator (@app.route('blabla'))
61#You can now acces this site on localhost:5000/page1 and on localhost:5000/page2 and they are both the same.
62
63#Since I dont want to make this "Grepper Tutorial" I am prabably going to make a 2cnd part if guys like this
64
65
66
67
68if __name__ == '__main__':
69    app.debug = True
70    app.run("0.0.0.0", 5000 , debug = True) #If you want to run youre website on a diffrent port,
71    #change this number ^
Laura
05 Jun 2019
1Flask is a web framework written in Python. 
2This means flask provides you with tools, libraries and technologies that allow you to build a web application.
3
4Here a a few resources for learning Flask (I have not personally used them before):
5	https://youtube.com/playlist?list=PLzMcBGfZo4-n4vJJybUVV3Un_NFS5EOgX
6    https://realpython.com/tutorials/flask/
7    https://opensource.com/article/18/4/flask
Michelle
11 Apr 2017
1These are by far the best Flask tutorials there are: https://youtube.com/playlist?list=PLzMcBGfZo4-n4vJJybUVV3Un_NFS5EOgX
similar questions
queries leading to this page
what is flask