#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Feb 19 08:40:55 2019
@author: vicky
"""
from flask import Flask
app = Flask(__name__)
@app.route('/')
def hello_world():
return 'Hello World!'
#路由: route() 装饰器把一个函数绑定到对应的 URL 上
#@app.route('/')
#def index():
# return 'Index Page'
#@app.route('/hello')
#def hello():
# return 'Hello World'
##给 URL 添加变量部分
#@app.route('/user/<username>')
#def show_user_profile(username):
# # show the user profile for that user
# return 'User %s' % username
#
#@app.route('/post/<int:post_id>')
#def show_post(post_id):
# # show the post with the given id, the id is an integer
# return 'Post %d' % post_id
##唯一 URL / 重定向行为
#访问一个结尾不带斜线的 URL 会被 Flask 重定向到带斜线的规范 URL 去
#@app.route('/projects/')
#def projects():
# return 'The project page'
#访问结尾带斜线的 URL 会产生一个 404 “Not Found” 错误。
#@app.route('/about')
#def about():
# return 'The about page'
# from flask import render_template
#@app.route('/hello/')
#@app.route('/hello/<name>')
#def hello(name=None):
# return 'fhfjhfyfhjf'+name
# #return render_template('hello.html', name=name)
#
#from flask import request
#
#with app.test_request_context('/hello', method='POST'):
# # now you can do something with the request until the
# # end of the with block, such as basic assertions:
# assert request.path == '/hello'
# assert request.method == 'POST'
#@app.route('/login', methods=['GET', 'POST'])
#def login():
# if request.method == 'POST':
# do_the_login()
# else:
# show_the_login_form()
#if __name__ == '__main__':
# app.run()
#app.run(host='0.0.0.0') #外部可访问的服务器
#app.run(debug=True) #调试模式