frog.py 629 B

12345678910111213141516171819202122232425262728
  1. from flask import Flask
  2. app=Flask(__name__)
  3. @app.route('/')
  4. def index():
  5. return '<h1>hello world!</h1>'
  6. @app.route('/hello/<name>')
  7. def hello(name):
  8. return '<h1>hello '+name+'!</h1>'
  9. @app.route('/book/<string:name>')
  10. def book(name):
  11. return '<h1>I like book 《%s》!</h1>'% name
  12. @app.route('/<int:num1>/plus/<int:num2>')
  13. def plus(num1,num2):
  14. return '<h1>%s+%s=%s</h1>'%(num1,num2,num1+num2)
  15. @app.route('/height/<float:num>/m')
  16. def height(num):
  17. cm=num*100
  18. return 'My height is %s cm!' % cm
  19. @app.route('/location/<path:location>')
  20. def whereami(location):
  21. return 'Your location is %s .' % location