hello.py-20190220

#!/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) #调试模式
    
    

 

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值