Home > Backend Development > Python Tutorial > python中Flask框架简单入门实例

python中Flask框架简单入门实例

WBOY
Release: 2016-06-06 11:22:12
Original
1253 people have browsed it

本文实例讲述了python中Flask框架的简单用法。分享给大家供大家参考。具体如下:

使用Flask框架的简单入门范例代码,如果你正学习Flask框架,可以参考下面的启动代码,这段代码可以在网页上输出“hello world”

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")
 )
Copy after login

希望本文所述对大家的Python程序设计有所帮助。

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template