首页 > 编程语言 > 详细

[Python] Create a minimal website in Python using the Flask Microframework

时间:2018-04-30 17:24:51      阅读:220      评论:0      收藏:0      [点我收藏+]

How to install Flask Use Flask to create a minimal website Build routes in Flask to respond to website endpoints Use Variable Rules to pass parts of the URL to your functions as keyword parameters

Install:

pip install Flask

 

Development Mode:

run_local.sh:

#!/bin/bash

export FLASK_APP=app.py
export FLASK_DEBUG=1
flask run

 

app.py:

from flask import Flask
app = Flask(__name__)

@app.route(/)
def hello_world():
    return Hello world!

@app.route(/foo/)
def foo():
    return The foo page

@app.route(/bar)
def bar():
    return The bar page

@app.route(/hello/)
@app.route(/hello/<name>)
def say_hello(name=None):
    return ‘Hello {}‘.format(user)

 

[Python] Create a minimal website in Python using the Flask Microframework

原文:https://www.cnblogs.com/Answer1215/p/8973838.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!