达所

Flask官网  https://dormousehole.readthedocs.io/en/latest/patterns/index.html#patterns

from flask import Flask,url_for
import json


app = Flask(__name__)
app.debug= True

@app.route('/')
def hello_world():
    return 'Hello World!'

@app.route('/user/<username>')
def show_user_proeile(username):
    return 'User %s' %username

@app.route('/post/<int:post_id>')
def show_post(post_id):
    return 'Post %s' %post_id

@app.route('/hello/<name>/')
def hello(name=None):
    data = {'a':name}
    return json.dumps(data)


if __name__ == '__main__':
    app.run()

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-10-12
  • 2022-12-23
  • 2021-12-02
  • 2021-06-08
  • 2021-07-12
  • 2022-12-23
猜你喜欢
  • 2021-09-08
  • 2021-12-26
  • 2022-12-23
  • 2022-02-16
  • 2021-07-20
相关资源
相似解决方案