本文实例讲述了python中Flask框架的简单用法。分享给大家供大家参考。具体如下:
使用Flask框架的简单入门范例代码,如果你正学习Flask框架,可以参考下面的启动代码,这段代码可以在网页上输出“hello world”
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
import os # Using Flask since Python doesn't have built-in session management from flask import Flask, session app = Flask(__name__) # Generate a secret random key for the session app.secret_key = os.urandom( 24 ) @app .route( '/' ) def index(): return "Hello world" if __name__ = = '__main__' : app.run( host = "0.0.0.0" , port = int ( "80" ) ) |
希望本文所述对大家的Python程序设计有所帮助。