Answers for "Flask"



pip install -U Flask
Posted by: Guest on April-13-2020


from flask import Flask
app = Flask(__name__)

def hello_world():
    return 'Hello, World!'
Posted by: Guest on June-11-2020


# This is a basic Flask Tutorial
# First of all, if something doesn't work, you messed up.
# Too start of, make a project folder and install flask with a venv or just normally.
# You can install flask with this command: pip install Flask
# (type this into you're terminal)
# I f you get an error message, it is because you a, dont have python3 installed,
# b: youre on a mac that has Python3 and python2 installed (this is probably the case)
# If you dont have python3 installed then go ahead and install it. If it is case b, then type in
# pip3 install Flask
# Now, lets start by making a file named
# You can return basic html or text when returning in the
# Hello World function. The @app.route('/') defines that the function
# Will return at the page '/'. Debug mode is turned on on and the website
# Will run at aka localhost:5000.

from flask import Flask #Import Flask
from flask import render_template #Import render template function
app = Flask(__name__)

def hello_world():
    return '''<h1>Welcome to Flask!</h1><a href=" /about">About Me!</a>'''

# You can also return a Template. For that, make a Templates folder
# and create a file named about.html inside of the Templates folder
# html file contents (copy and paste it without the hashtags):

#   <body>
#       <h1>About Me</h1>
#       <p>Hi, this is me, I am a Python programmer who is currently learning Flask!</p>
#       <a href="/">Home</a>
#   </body>

# (You can edit it if you want)

#Just for you info, you your Project folder should look like this:
#     ProjectFolder:
#       Templates:
#           about.html
# Lets make a site at localhost:5000/about and use the template we created

def about():
    return render_template("about.html")  # You can do this with every html file in the templates folder

#If you would like to have the same page with 2 diffrent urls (this works with as many as you want)
#You can do this:
def page1andpage2():
    return 'Page1 and pag2 are now the same!'
#ps: you dont have to name the function page1andpage2
#you can name every function as you like. It doesn't matter.
#The only thing that matters about the url is the decorator (@app.route('blabla'))
#You can now acces this site on localhost:5000/page1 and on localhost:5000/page2 and they are both the same.

#Since I dont want to make this "Grepper Tutorial" I am prabably going to make a 2cnd part if guys like this

if __name__ == '__main__':
    app.debug = True"", 5000 , debug = True) #If you want to run youre website on a diffrent port,
    #change this number ^
Posted by: Guest on April-12-2021


from flask import Flask
app = Flask('app')

def hello_world():
  return 'Hello, World!''', port=8080)
Posted by: Guest on September-15-2021


Flask is a Python framework for web development.

When creating simple static sites, there is no need to use backend frameworks.
However, when creating complex and large sites that are backend heavy,
you will want to use a backend framework. Currently, the 2 Python frameworks
that are the most useful to learn are Flask and Django.

Micro and light-weight framework that is easy to learn.

Complex, full-stack framework that is extremely powerful.

For smaller projects, Flask will work. However, for large ones, you might
consider learning Django. I suggest you learn Flask first and then Django.

Additionally, considering learning Node JS because even though it is in
Javascript, it is extremely popular.
Posted by: Guest on March-31-2021


$ flask run --host=
Posted by: Guest on May-16-2021


from flask import Flask, render_template

# Create a flask app
app = Flask(

# Index page
def hello():
  return "Hello World!"

if __name__ == '__main__':
  # Run the Flask app
Posted by: Guest on October-17-2021


Posted by: Guest on July-27-2021

Code answers related to "Shell/Bash"

Browse Popular Code Answers by Language