How to serve a webpage using python flask
Last modified by Leon Poon on 2021/03/23 13:17
First, set up a virtualenv.
In the virtualenv, install flask, then try out this .py file.
from flask import Flask
app = Flask(__name__)
@app.route('/', methods=['GET'])
def index():
return 'Hi'
app.run()
app = Flask(__name__)
@app.route('/', methods=['GET'])
def index():
return 'Hi'
app.run()
Run this script in the virtualenv. It will not exit.
Now you should be able to access http://localhost:5000/ in your web browser.