flask+web+ajax练习

from flask import Flask, url_for, request
from jinja2.utils import generate_lorem_ipsum
# from urllib.parse import urlparse, quote

app = Flask(__name__)


@app.route('/articles/')
def ajax_article(id):
    path = url_for('more_para', id=id)
    para_num = 2
    first_body = generate_lorem_ipsum(n=para_num)
    html = '''

文章%s

%s
''' % (id, first_body, para_num + 1, path) return html @app.route('/articles//more') def more_para(id): para_num = request.args.get('para_num') return '文章{}的第{}段
'.format(id, para_num) if __name__ == '__main__': app.run()

你可能感兴趣的:(flask+web+ajax练习)