How to serve a webpage using python flask

Last modified by Leon Poon on 2018/12/24 20:29

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()

Run this script in the virtualenv. It will not exit.

Now you should be able to access http://localhost:5000/ in your web browser.

Tags:
Created by Leon Poon on 2018/12/24 17:48
    

Need help?

If you need help with XWiki you can contact: