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=
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的更多相关文章

  1. [Python] Create Unique Unordered Collections in Python with Set

    A set is an unordered collection with no duplicate items in Python. In this lesson, you will learn h ...

  2. [Python] Create a Log for your Python application

    Print statements will get you a long way in monitoring the behavior of your application, but logging ...

  3. The Python web services developer: XML-RPC for Python

    原文地址:http://www.ibm.com/developerworks/webservices/library/ws-pyth10/index.html 摘要:概括地说,您可以将 XML-RPC ...

  4. Python开发【第一篇】Python基础之自定义模块和内置模块

    为什么要有模块,将代码归类.模块,用一砣代码实现了某个功能的代码集合. Python中叫模块,其他语言叫类库. 类似于函数式编程和面向过程编程,函数式编程则完成一个功能,其他代码用来调用即可,提供了代 ...

  5. 精通 Oracle+Python,第 6 部分:Python 支持 XML

    无可辩驳的是,XML 现在是软件中信息交换的实际标准. 因此,Oracle 数据库附带了各种与 XML 相关的增强和工具,它们统称为 Oracle XML DB.XML DB 包含一系列嵌入到数据库中 ...

  6. python基础系列教程——Python的安装与测试:python的IDE工具PyDev和pycharm,anaconda

    ---恢复内容开始--- python基础系列教程——Python的安装与测试:python的IDE工具PyDev和pycharm,anaconda 从头开启python的开发环境搭建.安装比较简单, ...

  7. Introspection in Python How to spy on your Python objects Guide to Python introspection

    Guide to Python introspection https://www.ibm.com/developerworks/library/l-pyint/ Guide to Python in ...

  8. [Python + Unit Testing] Write Your First Python Unit Test with pytest

    In this lesson you will create a new project with a virtual environment and write your first unit te ...

  9. PYTHON 100days学习笔记007-1:python数据类型补充(1)

    目录 day007:python数据类型补充(1) 1.数字Number 1.1 Python 数字类型转换 1.2 Python 数字运算 1.3 数学函数 1.4 随机数函数 1.5 三角函数 1 ...

随机推荐

  1. Java 8 实战 P3 Effective Java 8 programming

    目录 Chapter 8. Refactoring, testing, and debugging Chapter 9. Default methods Chapter 10. Using Optio ...

  2. .sh文件 编写格式

    http://blog.sina.com.cn/s/blog_54f82cc201010hfz.html 介绍: 1 开头 程序必须以下面的行开始(必须方在文件的第一行): #!/bin/sh 符号# ...

  3. 比较两个Json对象是否相等

    一个前端同事遇到的面试题,抽空写了写,也算是个积累 1.先准备三个工具方法,用于判断是否是对象类型,是否是数组,获取对象长度 function isObj(object) { return objec ...

  4. 计算某个时间段(2017-10-01 2017-12-01)内svn更新文件的MD5

    #!/bin/sh svn up svn log -v -r {$1}:{$2} | grep / | grep -v xxx | sort -f -u | uniq | awk -F 'xxxx' ...

  5. POJ 3083 BFS+DFS 40行

    题意:给你一个迷宫. 先输出当左转优先的时候走的路程长度,再输出当右转优先时走的路程长度,最后输出从起点到终点的最短路程长度. 嗯嗯 奴哥活跃气氛的题.随便写了写.. 此题 知道了思路以后就是水题了. ...

  6. 禁止tomcat扫描jar包的tld文件

    禁止tomcat扫描jar包的tld文件tomcat/conf/logging.properties 取消注释org.apache.jasper.compiler.TldLocationsCache. ...

  7. struts2标签(五)

    标签体系结构 jsp出现目的是为了取代servlet,结果逻辑代码,数据库代码都放到了jsp页面中. 为了解决jsp中代码过多的问题,struts2标签分为普通标签和UI标签. 使用struts2标签 ...

  8. Deutsch lernen (07)

    1. die Einführung, -en 介绍:引言,导论 Könnten Sie uns zuerst eine kleine Einführung über das Klonen geben. ...

  9. 读白帽子web安全笔记

    点击劫持 frame buseting if (top.location != location) { top.location = self.location } html5的sandbox属性   ...

  10. 与swift协议相关的技术

    一.协议定义与实现: 1.关联类型: 2.协议组合: 3.协议扩展: 4.协议实现. 二.协议使用: