from flask import Flask
import time
app = Flask(__name__)
@app.route('/')defindex():return'hello world';
@app.route('/now')defnow():return time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time()))if __name__ =='__main__':
app.run(host='localhost', port=80, debug=True)
3、启动服务
pydev debugger: process 2024is connecting
Connected to pydev debugger (build 201.7846.77)* Serving Flask app "api"(lazy loading)* Environment: production
WARNING: This is a development server. Do not use it in a production deployment.
Use a production WSGI server instead.* Debug mode: on
* Restarting with stat
pydev debugger: process 1012is connecting
* Debugger is active!
* Debugger PIN:227-495-718* Running on http://localhost:80/(Press CTRL+C to quit)