14
loading...
This website collects cookies to deliver better user experience
pip install virualenv
#activating:Linux
env/bin/activate
#windows
cd env\Scripts\activate
pip install flask
# or
pip3 install flask
# import Flask class
from flask import Flask
#instantiate flask app obj
app = Flask(__name__)
# decorator function(routing)
@app.route('/')
def index():
return 'Hello world!'
if __name__ == '__main__':
app.run(debug=True)
if __name__ == '__main__':
app.run()
#first we set the flask_app variable
# Linux
export FLASK_APP=app.run
#window
set FLASK_APP=app.run
# run it
flask run
http://127.0.0.1:5000
@app.route('/')
def index():
return 'Hello world!'
from flask import Flask, render_template
@app.route('/about')
def about():
return render_template('about.html')
<variable_name>
.<converter:variable_name>
@app.route('/age/<int:num>')
def age(num):
return f'<p>This Blog is {num} old.</p>'