#!/usr/bin/env python # encoding: utf-8 """ @version: v1.0 @author: cxa @file: hello.py.py @time: 2018/04/13 14:06 """ from flask import Flask app=Flask(__name__) htmlstr="""<html><head></head><body><div style="font-size:16px">this is my webpage,启动app.run(<em style="color:red">debug</em>=True)以后可以随时修改网页的内容而不用重启程序。</div></bodt></html>""" @app.route('/') @app.route('/hello') def hello_world(): return htmlstr if __name__ == "__main__": app.run(debug=True)
运行上面代码然后在浏览器中输入即可。http://127.0.0.1:5000/