码迷,mamicode.com
首页 > 编程语言 > 详细

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

时间:2018-04-30 17:55:18      阅读:177      评论:0      收藏:0      [点我收藏+]

标签:url   python   dev   oca   app   eve   format   int   key   

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

标签:url   python   dev   oca   app   eve   format   int   key   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!