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

Posted Answer1215

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了[Python] Create a minimal website in Python using the Flask Microframework相关的知识,希望对你有一定的参考价值。

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的主要内容,如果未能解决你的问题,请参考以下文章

python玄学建模:非线性规划

python Django Minimal App

python minimal_django_app.py

nodejs 询问不再在 python2 上使用的 python-minimal

Python LMFIT - 使用有界参数时,获取最小化的错误结果

带有类型推导的 swig python 模板函数