{"id":102036,"date":"2026-09-08T03:42:56","date_gmt":"2026-09-07T19:42:56","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/102036.html"},"modified":"2026-09-08T03:42:56","modified_gmt":"2026-09-07T19:42:56","slug":"%e4%b8%80%e6%96%87%e6%8e%8c%e6%8f%a1-jquery-flask-%e5%85%a8%e6%a0%88%e6%a0%b8%e5%bf%83%e7%9f%a5%e8%af%86%e7%82%b9%ef%bc%88%e5%89%8d%e7%ab%af%e4%ba%a4%e4%ba%92-%e5%90%8e%e7%ab%af%e6%8e%a5%e5%8f%a3","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/102036.html","title":{"rendered":"\u4e00\u6587\u638c\u63e1 jQuery + Flask \u5168\u6808\u6838\u5fc3\u77e5\u8bc6\u70b9\uff08\u524d\u7aef\u4ea4\u4e92 + \u540e\u7aef\u63a5\u53e3 + \u524d\u540e\u7aef\u8054\u8c03\uff09"},"content":{"rendered":"<h3>\u524d\u8a00<\/h3>\n<p>\u505a Web \u5f00\u53d1&#xff0c;\u672c\u8d28\u4e0a\u662f\u524d\u7aef &#043; \u540e\u7aef\u4e24\u534a&#xff1a;\u524d\u7aef\u8d1f\u8d23\u300c\u7528\u6237\u770b\u5230\u4ec0\u4e48\u3001\u70b9\u4e86\u6709\u4ec0\u4e48\u53cd\u5e94\u300d&#xff0c;\u540e\u7aef\u8d1f\u8d23\u300c\u6570\u636e\u4ece\u54ea\u6765\u3001\u5b58\u5230\u54ea\u53bb\u300d\u3002<\/p>\n<ul>\n<li>\u524d\u7aef&#xff1a;\u7528 jQuery \u505a\u4ea4\u4e92 \u2014\u2014 \u9009\u5143\u7d20\u3001\u6539\u5185\u5bb9\u3001\u7ed1\u4e8b\u4ef6\u3001\u53d1\u8bf7\u6c42\u3002<\/li>\n<li>\u540e\u7aef&#xff1a;\u7528 Flask \u505a\u63a5\u53e3 \u2014\u2014 \u63a5\u8bf7\u6c42\u3001\u5904\u7406\u6570\u636e\u3001\u67e5\u6570\u636e\u5e93\u3001\u8fd4\u56de\u7ed3\u679c\u3002<\/li>\n<\/ul>\n<p>\u672c\u6587\u628a\u8fd9\u4e24\u90e8\u5206\u7684\u6838\u5fc3\u77e5\u8bc6\u70b9\u6574\u5408\u6210\u4e00\u7bc7&#xff0c;\u91cd\u70b9\u8bb2\u6e05\u695a\u524d\u7aef\u53d1\u8bf7\u6c42 \u2194 \u540e\u7aef\u5904\u7406 \u2194 \u8fd4\u56de\u6570\u636e\u8fd9\u6761\u5b8c\u6574\u94fe\u8def\u3002\u8bfb\u5b8c\u5e76\u8dd1\u901a\u6587\u672b\u7684\u300c\u7559\u8a00\u677f\u300d\u793a\u4f8b&#xff0c;\u4f60\u5c31\u771f\u6b63\u5165\u95e8\u4e86\u5168\u6808\u5f00\u53d1\u3002<\/p>\n<p>&#x1f4a1; \u5173\u952e\u8ba4\u77e5&#xff1a;\u4f60\u5b66\u7684\u524d\u7aef $.ajax() \u548c\u540e\u7aef\u7684 &#064;app.route() \u662f\u4e00\u5bf9\u3002\u524d\u7aef\u53d1\u51fa\u8bf7\u6c42&#xff0c;\u540e\u7aef\u8def\u7531\u63a5\u6536\u5904\u7406&#xff0c;\u518d\u8fd4\u56de JSON&#xff0c;\u524d\u7aef\u518d\u663e\u793a\u3002\u7406\u89e3\u4e86\u8fd9\u5c42\u5bf9\u5e94\u5173\u7cfb&#xff0c;\u524d\u540e\u7aef\u5c31\u901a\u4e86\u3002<\/p>\n<\/p>\n<h2>\u7b2c\u4e00\u90e8\u5206&#xff1a;\u524d\u7aef\u7bc7 \u2014\u2014 jQuery \u6838\u5fc3\u77e5\u8bc6\u70b9<\/h2>\n<h3>1.1 jQuery \u662f\u4ec0\u4e48<\/h3>\n<p>jQuery \u662f\u4e00\u4e2a JavaScript \u51fd\u6570\u5e93&#xff0c;\u5c01\u88c5\u4e86\u539f\u751f JS \u7684 DOM \u64cd\u4f5c\u3001\u4e8b\u4ef6\u5904\u7406\u548c Ajax \u8bf7\u6c42&#xff0c;\u8ba9\u4ee3\u7801\u66f4\u7b80\u6d01\u3002\u5178\u578b\u5199\u6cd5\u662f $(\u9009\u62e9\u5668).\u65b9\u6cd5()\u3002<\/p>\n<p>\/\/ \u539f\u751f JS<br \/>\ndocument.getElementById(&#034;pageTitle&#034;).innerHTML &#061; &#034;\u65b0\u6807\u9898&#034;;<\/p>\n<p>\/\/ jQuery<br \/>\n$(&#034;#pageTitle&#034;).text(&#034;\u65b0\u6807\u9898&#034;);<\/p>\n<h3>1.2 \u6838\u5fc3\u8bed\u6cd5&#xff1a;$(\u9009\u62e9\u5668). \u65b9\u6cd5 ()<\/h3>\n<table>\n<tr>\u90e8\u5206\u542b\u4e49\u4f8b\u5b50<\/tr>\n<tbody>\n<tr>\n<td>$<\/td>\n<td>jQuery \u5165\u53e3&#xff0c;\u53ef\u7406\u89e3\u4e3a jQuery \u7684\u7b80\u5199<\/td>\n<td>\u2014<\/td>\n<\/tr>\n<tr>\n<td>$(\u9009\u62e9\u5668)<\/td>\n<td>\u5148\u9009\u4e2d\u5143\u7d20&#xff0c;\u8fd4\u56de jQuery \u5bf9\u8c61<\/td>\n<td>$(&#034;#id&#034;)\u3001$(&#034;.class&#034;)<\/td>\n<\/tr>\n<tr>\n<td>.\u65b9\u6cd5()<\/td>\n<td>\u5bf9\u9009\u4e2d\u7684\u5143\u7d20\u505a\u64cd\u4f5c<\/td>\n<td>.text()\u3001.css()\u3001.append()<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u8bb0\u4f4f&#xff1a;\u5148\u9009\u4e2d&#xff0c;\u518d\u64cd\u4f5c\u3002\u6240\u6709\u4ee3\u7801\u901a\u5e38\u5305\u5728 $(function(){ &#8230; }) \u91cc&#xff0c;\u7b49\u9875\u9762\u52a0\u8f7d\u5b8c\u518d\u6267\u884c\u3002<\/p>\n<h3>1.3 \u5143\u7d20\u9009\u62e9\u5668<\/h3>\n<p>$(&#034;#pageTitle&#034;)            \/\/ # \u6309 id \u627e&#xff08;\u552f\u4e00&#xff09;<br \/>\n$(&#034;.message&#034;)              \/\/ . \u6309 class \u627e&#xff08;\u6279\u91cf&#xff09;<\/p>\n<h3>1.4 \u5185\u5bb9\u64cd\u4f5c&#xff1a;.val () \u548c .text ()<\/h3>\n<p>$(&#034;#username&#034;).val(&#034;\u5f20\u4e09&#034;);       \/\/ \u8bfb\u5199\u8868\u5355\u503c&#xff08;input\/textarea\/select&#xff09;<br \/>\n$(&#034;#description&#034;).text(&#034;\u65b0\u6587\u5b57&#034;); \/\/ \u8bfb\u5199\u666e\u901a\u5143\u7d20\u7684\u7eaf\u6587\u672c<\/p>\n<p>\u65e0\u53c2\u6570 &#061; \u8bfb\u53d6&#xff0c;\u6709\u53c2\u6570 &#061; \u4fee\u6539\u3002.text() \u5f53\u7eaf\u6587\u672c&#xff0c;.html() \u5f53 HTML \u89e3\u6790\u3002<\/p>\n<h3>1.5 \u5c42\u7ea7\u5b9a\u4f4d&#xff1a;.parent () \/.siblings () \/.children ()<\/h3>\n<p>$(this).parent().css(&#034;border&#034;, &#034;2px solid red&#034;);      \/\/ \u76f4\u63a5\u7236\u5143\u7d20<br \/>\n$(this).siblings().css(&#034;background-color&#034;, &#034;#fee2e2&#034;); \/\/ \u5144\u5f1f\u5143\u7d20&#xff08;\u4e0d\u542b\u81ea\u5df1&#xff09;<br \/>\n$(&#034;#container&#034;).children().css(&#034;color&#034;, &#034;blue&#034;);       \/\/ \u76f4\u63a5\u5b50\u5143\u7d20<\/p>\n<h3>1.6 \u6837\u5f0f\u4fee\u6539&#xff1a;.css ()<\/h3>\n<p>$(&#034;#box&#034;).css(&#034;color&#034;, &#034;red&#034;);          \/\/ \u6539\u4e00\u4e2a\u5c5e\u6027<br \/>\n$(&#034;#box&#034;).css({ &#034;color&#034;: &#034;white&#034;,       \/\/ \u4e00\u6b21\u6539\u591a\u4e2a<br \/>\n                &#034;background-color&#034;: &#034;#2563eb&#034; });<br \/>\nvar c &#061; $(&#034;#box&#034;).css(&#034;color&#034;);         \/\/ \u8bfb\u53d6<\/p>\n<h3>1.7 \u52a8\u6001\u8ffd\u52a0&#xff1a;.append ()<\/h3>\n<p>$(&#034;#list&#034;).append(&#034;&lt;li&gt;\u65b0\u7684\u5217\u8868\u9879&lt;\/li&gt;&#034;);          \/\/ \u8ffd\u52a0 HTML \u5b57\u7b26\u4e32<br \/>\n$(&#034;#list&#034;).append($(&#034;&lt;li&gt;&lt;\/li&gt;&#034;).text(&#034;\u5b89\u5168\u5199\u6cd5&#034;)); \/\/ \u5148\u5efa\u5143\u7d20\u518d\u5199\u5165&#xff08;\u9632 XSS&#xff09;<\/p>\n<h3>1.8 Ajax \u8bf7\u6c42&#xff1a;$.ajax () \u548c $.post ()<\/h3>\n<p>$.ajax({<br \/>\n  url: &#034;\/api\/posts\/1&#034;,<br \/>\n  type: &#034;GET&#034;,<br \/>\n  dataType: &#034;json&#034;,<br \/>\n  success: function(res) { $(&#034;#result&#034;).text(res.title); },  \/\/ \u6210\u529f<br \/>\n  error: function() { console.log(&#034;\u5931\u8d25&#034;); }                  \/\/ \u5931\u8d25<br \/>\n});<\/p>\n<p>$.post(&#034;\/api\/posts&#034;, { title: &#034;\u6807\u9898&#034; }, function(res) {<br \/>\n  console.log(res);<br \/>\n}, &#034;json&#034;);<\/p>\n<h3>1.9 \u524d\u7aef\u65b9\u6cd5\u901f\u67e5\u8868<\/h3>\n<table>\n<tr>\u77e5\u8bc6\u70b9\u4f5c\u7528\u5178\u578b\u5199\u6cd5<\/tr>\n<tbody>\n<tr>\n<td>$(&#034;#id&#034;)<\/td>\n<td>\u6309 id \u9009\u552f\u4e00\u5143\u7d20<\/td>\n<td>$(&#034;#title&#034;)<\/td>\n<\/tr>\n<tr>\n<td>$(&#034;.class&#034;)<\/td>\n<td>\u6309 class \u6279\u91cf\u9009<\/td>\n<td>$(&#034;.item&#034;)<\/td>\n<\/tr>\n<tr>\n<td>.val()<\/td>\n<td>\u8bfb \/ \u5199\u8868\u5355\u503c<\/td>\n<td>$(&#034;#name&#034;).val()<\/td>\n<\/tr>\n<tr>\n<td>.text()<\/td>\n<td>\u8bfb \/ \u5199\u7eaf\u6587\u672c<\/td>\n<td>$(&#034;#msg&#034;).text(&#034;\u5b8c\u6210&#034;)<\/td>\n<\/tr>\n<tr>\n<td>.parent()<\/td>\n<td>\u627e\u7236\u5143\u7d20<\/td>\n<td>$(this).parent()<\/td>\n<\/tr>\n<tr>\n<td>.siblings()<\/td>\n<td>\u627e\u5144\u5f1f\u5143\u7d20<\/td>\n<td>$(this).siblings()<\/td>\n<\/tr>\n<tr>\n<td>.children()<\/td>\n<td>\u627e\u5b50\u5143\u7d20<\/td>\n<td>$(&#034;#box&#034;).children()<\/td>\n<\/tr>\n<tr>\n<td>.css()<\/td>\n<td>\u8bfb \/ \u6539\u6837\u5f0f<\/td>\n<td>$(&#034;#b&#034;).css(&#034;color&#034;,&#034;red&#034;)<\/td>\n<\/tr>\n<tr>\n<td>.append()<\/td>\n<td>\u672b\u5c3e\u8ffd\u52a0<\/td>\n<td>$(&#034;#list&#034;).append(&#034;&lt;li&gt;x&lt;\/li&gt;&#034;)<\/td>\n<\/tr>\n<tr>\n<td>$.ajax() \/ $.post()<\/td>\n<td>\u5f02\u6b65\u8bf7\u6c42\u540e\u7aef<\/td>\n<td>$.post(url, data, cb)<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<hr \/>\n<h2>\u7b2c\u4e8c\u90e8\u5206&#xff1a;\u540e\u7aef\u7bc7 \u2014\u2014 Flask \u5fc5\u638c\u63e1\u77e5\u8bc6\u70b9<\/h2>\n<p>\u505a\u540e\u7aef&#xff0c;\u6838\u5fc3\u94fe\u8def\u662f&#xff1a;\u63a5\u8bf7\u6c42 \u2192 \u5904\u7406\u6570\u636e \u2192 \u67e5\u6570\u636e\u5e93 \u2192 \u8fd4\u56de\u7ed3\u679c\u3002\u4e0b\u9762\u6bcf\u4e2a\u77e5\u8bc6\u70b9\u90fd\u914d Flask \u4ee3\u7801\u3002<\/p>\n<h3>2.1 Python \u57fa\u7840&#xff08;\u5730\u57fa&#xff09;<\/h3>\n<p>\u53d8\u91cf\u3001\u51fd\u6570\u3001if\/for\u3001\u5b57\u5178\u3001\u5217\u8868\u3001\u7c7b\u3002\u91cd\u70b9\u8865\u5b57\u5178&#xff08;\u540e\u7aef\u5904\u7406 JSON \u5168\u9760\u5b83&#xff09;&#xff1a;<\/p>\n<p>user &#061; {&#034;name&#034;: &#034;\u5f20\u4e09&#034;, &#034;age&#034;: 20}<br \/>\nprint(user[&#034;name&#034;])          # \u5f20\u4e09<\/p>\n<h3>2.2 HTTP \u534f\u8bae&#xff08;\u5730\u57fa&#xff0c;\u6700\u6613\u5ffd\u7565&#xff09;<\/h3>\n<p>\u6d4f\u89c8\u5668\u548c\u670d\u52a1\u5668\u5bf9\u8bdd\u7684\u89c4\u5219&#xff1a;<\/p>\n<ul>\n<li>\u8bf7\u6c42&#xff1a;\u6d4f\u89c8\u5668\u53d1\u300c\u8bbf\u95ee \/user\/1&#xff0c;\u65b9\u6cd5 GET&#xff0c;\u5e26\u6570\u636e xxx\u300d<\/li>\n<li>\u54cd\u5e94&#xff1a;\u670d\u52a1\u5668\u56de\u300c\u72b6\u6001\u7801 200&#xff0c;\u5185\u5bb9 JSON\u300d<\/li>\n<li>GET &#061; \u53d6\u6570\u636e&#xff08;\u67e5&#xff09;&#xff1b;POST &#061; \u63d0\u4ea4\u6570\u636e&#xff08;\u589e\u6539&#xff09;<\/li>\n<li>\u72b6\u6001\u7801&#xff1a;200 \u6210\u529f\u3001404 \u6ca1\u627e\u5230\u3001500 \u670d\u52a1\u5668\u51fa\u9519<\/li>\n<\/ul>\n<p>\u524d\u7aef\u7684 $.get() \/ $.post() \u5c31\u662f\u5411 Flask \u53d1 HTTP \u8bf7\u6c42&#xff0c;\u540e\u7aef\u518d\u54cd\u5e94\u3002\u524d\u7aef Ajax \u2194 \u540e\u7aef\u8def\u7531&#xff0c;\u662f\u4e00\u5bf9\u3002<\/p>\n<h3>2.3 Flask \u8def\u7531<\/h3>\n<p>&#064;app.route \u628a\u300c\u7f51\u5740\u300d\u548c\u300c\u51fd\u6570\u300d\u7ed1\u8d77\u6765&#xff1a;<\/p>\n<p>from flask import Flask<br \/>\napp &#061; Flask(__name__)<\/p>\n<p>&#064;app.route(&#039;\/&#039;)                  # \u6839\u8def\u5f84<br \/>\ndef index():<br \/>\n    return &#034;\u9996\u9875&#034;<\/p>\n<p>&#064;app.route(&#039;\/user\/&lt;int:uid&gt;&#039;)    # \u8def\u5f84\u53c2\u6570 \/user\/123<br \/>\ndef user(uid):<br \/>\n    return f&#034;\u8fd9\u662f\u7528\u6237 {uid} \u53f7&#034;<\/p>\n<h3>2.4 \u8bf7\u6c42\u4e0e\u54cd\u5e94&#xff08;\u6838\u5fc3&#xff0c;\u5fc5\u987b\u719f\u7ec3&#xff09;<\/h3>\n<p>\u540e\u7aef\u6700\u91cd\u8981\u7684\u80fd\u529b&#xff1a;\u62ff\u524d\u7aef\u6570\u636e\u3001\u8fd4\u56de\u6570\u636e\u7ed9\u524d\u7aef\u3002<\/p>\n<p>from flask import request, jsonify, render_template<\/p>\n<p>&#064;app.route(&#039;\/login&#039;, methods&#061;[&#039;GET&#039;, &#039;POST&#039;])<br \/>\ndef login():<br \/>\n    if request.method &#061;&#061; &#039;POST&#039;:<br \/>\n        username &#061; request.form.get(&#039;username&#039;)   # \u62ff\u8868\u5355\u6570\u636e<br \/>\n        # \u62ff JSON&#xff1a;data &#061; request.get_json()<br \/>\n        return jsonify({&#034;msg&#034;: &#034;\u767b\u5f55\u6210\u529f&#034;, &#034;user&#034;: username})<br \/>\n    return render_template(&#039;login.html&#039;)          # GET \u8fd4\u56de\u9875\u9762<\/p>\n<table>\n<tr>\u5bf9\u8c61 \/ \u51fd\u6570\u4f5c\u7528<\/tr>\n<tbody>\n<tr>\n<td>request.args.get()<\/td>\n<td>\u62ff URL \u67e5\u8be2\u53c2\u6570 ?name&#061;xx<\/td>\n<\/tr>\n<tr>\n<td>request.form.get()<\/td>\n<td>\u62ff\u8868\u5355\u6570\u636e<\/td>\n<\/tr>\n<tr>\n<td>request.get_json()<\/td>\n<td>\u62ff JSON \u6570\u636e&#xff08;\u914d $.ajax&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>jsonify()<\/td>\n<td>\u8fd4\u56de JSON<\/td>\n<\/tr>\n<tr>\n<td>render_template()<\/td>\n<td>\u8fd4\u56de HTML \u9875\u9762<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>2.5 \u6570\u636e\u5e93 CRUD&#xff08;\u6838\u5fc3&#xff0c;\u540e\u7aef\u771f\u6b63\u7684\u4ef7\u503c&#xff09;<\/h3>\n<p>\u540e\u7aef 90% \u7684\u5de5\u4f5c\u662f\u300c\u5b58\u6570\u636e\u3001\u67e5\u6570\u636e\u300d\u3002\u7528 SQLAlchemy&#xff1a;<\/p>\n<p>class User(db.Model):                    # \u4e00\u5f20&#034;\u7528\u6237&#034;\u8868<br \/>\n    id &#061; db.Column(db.Integer, primary_key&#061;True)<br \/>\n    name &#061; db.Column(db.String(80))<\/p>\n<p># \u589e\u5220\u6539\u67e5&#xff08;CRUD&#xff09;\u2014\u2014 \u540e\u7aef\u56db\u5927\u57fa\u672c\u529f<br \/>\nuser &#061; User(name&#061;&#034;\u5f20\u4e09&#034;)                  # Create \u589e<br \/>\ndb.session.add(user); db.session.commit()<\/p>\n<p>u &#061; User.query.get(1)                    # Read \u67e5<br \/>\nu.name &#061; &#034;\u674e\u56db&#034;; db.session.commit()      # Update \u6539<\/p>\n<p>db.session.delete(u); db.session.commit() # Delete \u5220<\/p>\n<p>CRUD&#xff08;\u589e\u5220\u6539\u67e5&#xff09;\u662f\u540e\u7aef\u6700\u6838\u5fc3\u7684\u56db\u4e2a\u52a8\u4f5c&#xff0c;\u4e00\u5207\u529f\u80fd&#xff08;\u6ce8\u518c\u3001\u53d1\u6587\u7ae0\u3001\u4e0b\u5355&#xff09;\u672c\u8d28\u90fd\u662f\u5b83\u4eec\u3002<\/p>\n<h3>2.6 \u8fd4\u56de JSON \u63a5\u53e3&#xff08;\u6838\u5fc3&#xff0c;\u8fde\u63a5\u524d\u7aef&#xff09;<\/h3>\n<p>\u524d\u7aef Ajax \u8981\u7684\u662f\u6570\u636e&#xff0c;\u4e0d\u662f\u6574\u9875 HTML\u3002\u6240\u4ee5\u540e\u7aef\u8981\u5199\u300c\u63a5\u53e3\u300d&#xff1a;<\/p>\n<p>&#064;app.route(&#039;\/api\/posts&#039;)<br \/>\ndef posts():<br \/>\n    data &#061; [{&#034;id&#034;: 1, &#034;title&#034;: &#034;\u7b2c\u4e00\u7bc7&#034;}, {&#034;id&#034;: 2, &#034;title&#034;: &#034;\u7b2c\u4e8c\u7bc7&#034;}]<br \/>\n    return jsonify(data)   # \u8fd4\u56de JSON&#xff0c;\u524d\u7aef $.ajax \u63a5\u6536<\/p>\n<h3>2.7 \u6a21\u677f\u6e32\u67d3 Jinja2&#xff08;\u505a\u300c\u4e0d\u5206\u79bb\u300d\u9875\u9762\u65f6\u7528&#xff09;<\/h3>\n<p>\u5728 HTML \u91cc\u5199 Python \u903b\u8f91&#xff1a;<\/p>\n<p>&lt;ul&gt;<br \/>\n  {% for post in posts %}<br \/>\n    &lt;li&gt;{{ post.title }}&lt;\/li&gt;   &lt;!&#8211; \u8f93\u51fa\u53d8\u91cf &#8211;&gt;<br \/>\n  {% endfor %}<br \/>\n&lt;\/ul&gt;<br \/>\n{% if user %} \u4f60\u597d&#xff0c;{{ user.name }} {% endif %}<\/p>\n<h3>2.8 \u4f1a\u8bdd Session&#xff08;\u505a\u767b\u5f55\u7528&#xff09;<\/h3>\n<p>from flask import session<br \/>\nsession[&#034;user_id&#034;] &#061; 1          # \u5b58\u767b\u5f55\u72b6\u6001<br \/>\nsession.pop(&#034;user_id&#034;, None)    # \u9000\u51fa\u767b\u5f55\u6e05\u9664<\/p>\n<h3>2.9 \u540e\u7aef\u77e5\u8bc6\u70b9\u901f\u67e5\u8868<\/h3>\n<table>\n<tr>\u77e5\u8bc6\u70b9\u4f5c\u7528\u5173\u952e\u4ee3\u7801<\/tr>\n<tbody>\n<tr>\n<td>Python \u57fa\u7840<\/td>\n<td>\u5199\u903b\u8f91\u7684\u5730\u57fa<\/td>\n<td>\u53d8\u91cf \/ \u51fd\u6570 \/ \u5b57\u5178<\/td>\n<\/tr>\n<tr>\n<td>HTTP<\/td>\n<td>\u524d\u540e\u7aef\u5bf9\u8bdd\u89c4\u5219<\/td>\n<td>GET\/POST\/ \u72b6\u6001\u7801<\/td>\n<\/tr>\n<tr>\n<td>\u8def\u7531<\/td>\n<td>\u7f51\u5740 \u2192 \u51fd\u6570<\/td>\n<td>&#064;app.route(&#039;\/x&#039;)<\/td>\n<\/tr>\n<tr>\n<td>\u8bf7\u6c42<\/td>\n<td>\u62ff\u524d\u7aef\u6570\u636e<\/td>\n<td>request.form \/ request.get_json()<\/td>\n<\/tr>\n<tr>\n<td>\u54cd\u5e94<\/td>\n<td>\u8fd4\u56de\u7ed3\u679c<\/td>\n<td>jsonify() \/ render_template()<\/td>\n<\/tr>\n<tr>\n<td>\u6570\u636e\u5e93<\/td>\n<td>\u5b58 \/ \u67e5\u6570\u636e<\/td>\n<td>SQLAlchemy CRUD<\/td>\n<\/tr>\n<tr>\n<td>\u63a5\u53e3<\/td>\n<td>\u8fd4\u56de JSON<\/td>\n<td>jsonify(data)<\/td>\n<\/tr>\n<tr>\n<td>\u6a21\u677f<\/td>\n<td>\u52a8\u6001\u751f\u6210\u9875\u9762<\/td>\n<td>{{ \u53d8\u91cf }} {% for %}<\/td>\n<\/tr>\n<tr>\n<td>\u4f1a\u8bdd<\/td>\n<td>\u8bb0\u4f4f\u767b\u5f55\u72b6\u6001<\/td>\n<td>session<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<hr \/>\n<h2>\u7b2c\u4e09\u90e8\u5206&#xff1a;\u524d\u540e\u7aef\u8054\u8c03 \u2014\u2014 \u6253\u901a\u5b8c\u6574\u94fe\u8def<\/h2>\n<h3>3.1 \u8054\u8c03\u7684\u6838\u5fc3\u6d41\u7a0b<\/h3>\n<p>\u4e00\u6761\u5b8c\u6574\u7684\u524d\u540e\u7aef\u4ea4\u4e92\u94fe\u8def\u662f\u8fd9\u6837\u7684&#xff1a;<\/p>\n<p>\u524d\u7aef jQuery                     \u540e\u7aef Flask<br \/>\n\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500<br \/>\n$.post(&#034;\/api\/messages&#034;,   \u2500\u2500\u2192   &#064;app.route(&#039;\/api\/messages&#039;, methods&#061;[&#039;POST&#039;])<br \/>\n   { content: &#034;\u4f60\u597d&#034; })              request.form.get(&#034;content&#034;)   \u2190 \u6536\u6570\u636e<br \/>\n                                        \u2193 \u5b58\u6570\u636e\u5e93<br \/>\n                                     db.session.add(&#8230;); commit()<br \/>\n                                     return jsonify({&#8230;})        \u2190 \u8fd4 JSON<br \/>\nsuccess: function(res)    \u2190\u2500\u2500   &#xff08;\u54cd\u5e94\u8fd4\u56de\u7ed9\u524d\u7aef&#xff09;<br \/>\n   $(&#034;#list&#034;).append(&#8230;)         \u524d\u7aef\u628a\u8fd4\u56de\u7684\u6570\u636e\u663e\u793a\u51fa\u6765<\/p>\n<p>\u8bb0\u4f4f\u8fd9\u56db\u6b65&#xff1a;\u2460 \u524d\u7aef\u53d1\u8bf7\u6c42 \u2192 \u2461 \u540e\u7aef\u6536\u6570\u636e \u2192 \u2462 \u540e\u7aef\u5b58\u5e93 \/ \u67e5\u5e93 \u2192 \u2463 \u540e\u7aef\u8fd4 JSON&#xff0c;\u524d\u7aef\u663e\u793a\u3002<\/p>\n<h3>3.2 \u5b8c\u6574\u793a\u4f8b&#xff1a;\u7559\u8a00\u677f&#xff08;\u524d\u540e\u7aef\u8054\u8c03\u5b9e\u6218&#xff09;<\/h3>\n<p>\u4e00\u4e2a\u6700\u7b80\u7559\u8a00\u677f&#xff0c;\u628a\u524d\u9762\u6240\u6709\u77e5\u8bc6\u4e32\u8d77\u6765\u3002<\/p>\n<p>\u540e\u7aef app.py&#xff1a;<\/p>\n<p>from flask import Flask, render_template, request, jsonify<br \/>\nfrom flask_sqlalchemy import SQLAlchemy<\/p>\n<p>app &#061; Flask(__name__)<br \/>\napp.config[&#039;SQLALCHEMY_DATABASE_URI&#039;] &#061; &#039;sqlite:\/\/\/message.db&#039;<br \/>\ndb &#061; SQLAlchemy(app)<\/p>\n<p>class Message(db.Model):                       # \u7559\u8a00\u8868<br \/>\n    id &#061; db.Column(db.Integer, primary_key&#061;True)<br \/>\n    content &#061; db.Column(db.String(200))<\/p>\n<p>&#064;app.route(&#039;\/&#039;)<br \/>\ndef index():<br \/>\n    return render_template(&#039;index.html&#039;)       # \u8fd4\u56de\u9875\u9762<\/p>\n<p>&#064;app.route(&#039;\/api\/messages&#039;, methods&#061;[&#039;GET&#039;])   # \u67e5&#xff1a;\u8fd4\u56de\u6240\u6709\u7559\u8a00<br \/>\ndef get_messages():<br \/>\n    msgs &#061; Message.query.all()<br \/>\n    return jsonify([{&#034;id&#034;: m.id, &#034;content&#034;: m.content} for m in msgs])<\/p>\n<p>&#064;app.route(&#039;\/api\/messages&#039;, methods&#061;[&#039;POST&#039;])  # \u589e&#xff1a;\u65b0\u589e\u4e00\u6761\u7559\u8a00<br \/>\ndef add_message():<br \/>\n    content &#061; request.form.get(&#034;content&#034;)      # \u6536\u524d\u7aef\u6570\u636e<br \/>\n    msg &#061; Message(content&#061;content)<br \/>\n    db.session.add(msg)                        # \u5b58\u5e93<br \/>\n    db.session.commit()<br \/>\n    return jsonify({&#034;id&#034;: msg.id, &#034;content&#034;: msg.content})<\/p>\n<p>if __name__ &#061;&#061; &#039;__main__&#039;:<br \/>\n    with app.app_context():<br \/>\n        db.create_all()                        # \u5efa\u8868<br \/>\n    app.run(port&#061;5200, debug&#061;True)<\/p>\n<p>\u524d\u7aef templates\/index.html&#xff1a;<\/p>\n<p>&lt;script src&#061;&#034;https:\/\/code.jquery.com\/jquery-3.7.1.min.js&#034;&gt;&lt;\/script&gt;<\/p>\n<p>&lt;input id&#061;&#034;content&#034; placeholder&#061;&#034;\u8bf4\u70b9\u4ec0\u4e48&#034;&gt;<br \/>\n&lt;button id&#061;&#034;send&#034;&gt;\u53d1\u5e03&lt;\/button&gt;<br \/>\n&lt;ul id&#061;&#034;list&#034;&gt;&lt;\/ul&gt;<\/p>\n<p>&lt;script&gt;<br \/>\n$(function () {<br \/>\n    \/\/ \u9875\u9762\u52a0\u8f7d\u65f6&#xff1a;\u62c9\u53d6\u6240\u6709\u7559\u8a00\u5e76\u663e\u793a<br \/>\n    $.get(&#034;\/api\/messages&#034;, function (list) {<br \/>\n        list.forEach(function (m) {<br \/>\n            $(&#034;#list&#034;).append($(&#034;&lt;li&gt;&lt;\/li&gt;&#034;).text(m.content));<br \/>\n        });<br \/>\n    });<\/p>\n<p>    \/\/ \u70b9\u51fb\u53d1\u5e03&#xff1a;\u63d0\u4ea4\u7559\u8a00&#xff0c;\u6210\u529f\u540e\u8ffd\u52a0\u5230\u5217\u8868<br \/>\n    $(&#034;#send&#034;).click(function () {<br \/>\n        var content &#061; $(&#034;#content&#034;).val().trim();      \/\/ 1. \u8bfb\u8f93\u5165\u6846<br \/>\n        if (content &#061;&#061;&#061; &#034;&#034;) { alert(&#034;\u5185\u5bb9\u4e0d\u80fd\u4e3a\u7a7a&#034;); return; }<\/p>\n<p>        $.post(&#034;\/api\/messages&#034;, { content: content },   \/\/ 2. \u53d1\u8bf7\u6c42\u7ed9\u540e\u7aef<br \/>\n            function (res) {                            \/\/ 3. \u540e\u7aef\u8fd4\u56de\u540e<br \/>\n                $(&#034;#list&#034;).append($(&#034;&lt;li&gt;&lt;\/li&gt;&#034;).text(res.content)); \/\/ 4. \u663e\u793a<br \/>\n                $(&#034;#content&#034;).val(&#034;&#034;);<br \/>\n            }, &#034;json&#034;);<br \/>\n    });<br \/>\n});<br \/>\n&lt;\/script&gt;<\/p>\n<p>\u8fd9\u4e2a\u4f8b\u5b50\u5b8c\u6574\u8dd1\u901a\u4e86\u300c\u524d\u7aef jQuery \u53d1\u8bf7\u6c42 \u2192 \u540e\u7aef Flask \u6536\u6570\u636e\u5b58\u5e93 \u2192 \u8fd4\u56de JSON \u2192 \u524d\u7aef\u663e\u793a\u300d\u3002\u4f60\u524d\u9762\u7684 jQuery \u9009\u62e9\u5668\u3001.val()\u3001.append()\u3001.click()\u3001$.get()\/$.post()&#xff0c;\u548c\u540e\u7aef\u7684\u8def\u7531\u3001request\u3001jsonify\u3001\u6570\u636e\u5e93 CRUD&#xff0c;\u5168\u90fd\u5728\u8fd9\u91cc\u7528\u4e0a\u4e86\u3002<\/p>\n<h3>3.3 \u5b66\u4e60\u8def\u7ebf<\/h3>\n<li>\u2705 \u524d\u7aef&#xff1a;jQuery \u9009\u62e9\u5668\u3001\u5185\u5bb9\u64cd\u4f5c\u3001\u4e8b\u4ef6\u3001Ajax&#xff08;\u4f60\u5df2\u5b66&#xff09;<\/li>\n<li>\u2b1c \u540e\u7aef\u57fa\u7840&#xff1a;Flask \u8def\u7531 &#043; request\/jsonify<\/li>\n<li>\u2b1c \u6570\u636e\u5e93&#xff1a;SQLAlchemy \u589e\u5220\u6539\u67e5&#xff08;CRUD&#xff09;<\/li>\n<li>\u2b1c \u8054\u8c03&#xff1a;\u8dd1\u901a\u300c\u7559\u8a00\u677f\u300d\u8fd9\u4e2a\u524d\u540e\u7aef\u5b8c\u6574\u6d41\u7a0b<\/li>\n<li>\u2b1c \u8fdb\u9636&#xff1a;Session \u767b\u5f55\u3001\u84dd\u56fe\u6a21\u5757\u5316\u3001RESTful\u3001\u90e8\u7f72\u3001\u5b89\u5168<\/li>\n<h3>\u7ed3\u8bed<\/h3>\n<p>\u672c\u6587\u628a jQuery \u524d\u7aef \u548c Flask \u540e\u7aef \u4e24\u534a\u6574\u5408\u6210\u4e00\u6761\u5b8c\u6574\u94fe\u8def&#xff1a;<\/p>\n<ul>\n<li>\u524d\u7aef\u5fc5\u638c\u63e1&#xff1a;\u9009\u62e9\u5668\u3001.val()\/.text()\u3001\u5c42\u7ea7\u5b9a\u4f4d\u3001.css()\u3001.append()\u3001$.ajax()\/$.post()&#xff1b;<\/li>\n<li>\u540e\u7aef\u5fc5\u638c\u63e1&#xff1a;Python \u57fa\u7840\u3001HTTP \u6982\u5ff5\u3001Flask \u8def\u7531\u3001request\/jsonify\u3001\u6570\u636e\u5e93 CRUD\u3001\u8fd4\u56de JSON \u63a5\u53e3&#xff1b;<\/li>\n<li>\u6253\u901a\u7684\u5173\u952e&#xff1a;\u524d\u7aef Ajax \u2194 \u540e\u7aef\u8def\u7531&#xff0c;\u56db\u6b65\u8d70\u901a\u300c\u53d1\u8bf7\u6c42 \u2192 \u6536\u6570\u636e \u2192 \u5b58\u5e93 \u2192 \u8fd4 JSON\u300d\u3002<\/li>\n<\/ul>\n<p>\u638c\u63e1\u8fd9\u4e9b&#xff0c;\u4f60\u5c31\u8fc8\u8fdb\u4e86\u5168\u6808\u5f00\u53d1\u7684\u5927\u95e8\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u524d\u8a00\u505a Web \u5f00\u53d1&#xff0c;\u672c\u8d28\u4e0a\u662f\u524d\u7aef  \u540e\u7aef\u4e24\u534a&#xff1a;\u524d\u7aef\u8d1f\u8d23\u300c\u7528\u6237\u770b\u5230\u4ec0\u4e48\u3001\u70b9\u4e86\u6709\u4ec0\u4e48\u53cd\u5e94\u300d&#xff0c;\u540e\u7aef\u8d1f\u8d23\u300c\u6570\u636e\u4ece\u54ea\u6765\u3001\u5b58\u5230\u54ea\u53bb\u300d\u3002\u524d\u7aef&#xff1a;\u7528 jQuery \u505a\u4ea4\u4e92 \u2014\u2014 \u9009\u5143\u7d20\u3001\u6539\u5185\u5bb9\u3001\u7ed1\u4e8b\u4ef6\u3001\u53d1\u8bf7\u6c42\u3002\u540e\u7aef&#xff1a;\u7528 Flask \u505a\u63a5\u53e3 \u2014\u2014 \u63a5\u8bf7\u6c42\u3001\u5904\u7406\u6570\u636e\u3001\u67e5\u6570\u636e\u5e93\u3001\u8fd4\u56de\u7ed3\u679c\u3002\u672c\u6587\u628a\u8fd9\u4e24\u90e8\u5206\u7684\u6838\u5fc3\u77e5\u8bc6\u70b9\u6574\u5408\u6210\u4e00\u7bc7&#xff0c;\u91cd\u70b9\u8bb2\u6e05\u695a\u524d\u7aef\u53d1\u8bf7\u6c42 \u2194 \u540e\u7aef\u5904\u7406 \u2194 \u8fd4\u56de\u6570\u636e\u8fd9\u6761\u5b8c\u6574\u94fe\u8def\u3002\u8bfb\u5b8c\u5e76\u8dd1\u901a\u6587\u672b\u7684\u300c\u7559\u8a00\u677f\u300d\u793a<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[11660,11661,153,3237,87],"topic":[],"class_list":["post-102036","post","type-post","status-publish","format-standard","hentry","category-server","tag-web","tag-11661","tag-flask","tag-jquery","tag-87"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u4e00\u6587\u638c\u63e1 jQuery + Flask \u5168\u6808\u6838\u5fc3\u77e5\u8bc6\u70b9\uff08\u524d\u7aef\u4ea4\u4e92 + \u540e\u7aef\u63a5\u53e3 + \u524d\u540e\u7aef\u8054\u8c03\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/102036.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u4e00\u6587\u638c\u63e1 jQuery + Flask \u5168\u6808\u6838\u5fc3\u77e5\u8bc6\u70b9\uff08\u524d\u7aef\u4ea4\u4e92 + \u540e\u7aef\u63a5\u53e3 + \u524d\u540e\u7aef\u8054\u8c03\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u524d\u8a00\u505a Web \u5f00\u53d1&#xff0c;\u672c\u8d28\u4e0a\u662f\u524d\u7aef \u540e\u7aef\u4e24\u534a&#xff1a;\u524d\u7aef\u8d1f\u8d23\u300c\u7528\u6237\u770b\u5230\u4ec0\u4e48\u3001\u70b9\u4e86\u6709\u4ec0\u4e48\u53cd\u5e94\u300d&#xff0c;\u540e\u7aef\u8d1f\u8d23\u300c\u6570\u636e\u4ece\u54ea\u6765\u3001\u5b58\u5230\u54ea\u53bb\u300d\u3002\u524d\u7aef&#xff1a;\u7528 jQuery \u505a\u4ea4\u4e92 \u2014\u2014 \u9009\u5143\u7d20\u3001\u6539\u5185\u5bb9\u3001\u7ed1\u4e8b\u4ef6\u3001\u53d1\u8bf7\u6c42\u3002\u540e\u7aef&#xff1a;\u7528 Flask \u505a\u63a5\u53e3 \u2014\u2014 \u63a5\u8bf7\u6c42\u3001\u5904\u7406\u6570\u636e\u3001\u67e5\u6570\u636e\u5e93\u3001\u8fd4\u56de\u7ed3\u679c\u3002\u672c\u6587\u628a\u8fd9\u4e24\u90e8\u5206\u7684\u6838\u5fc3\u77e5\u8bc6\u70b9\u6574\u5408\u6210\u4e00\u7bc7&#xff0c;\u91cd\u70b9\u8bb2\u6e05\u695a\u524d\u7aef\u53d1\u8bf7\u6c42 \u2194 \u540e\u7aef\u5904\u7406 \u2194 \u8fd4\u56de\u6570\u636e\u8fd9\u6761\u5b8c\u6574\u94fe\u8def\u3002\u8bfb\u5b8c\u5e76\u8dd1\u901a\u6587\u672b\u7684\u300c\u7559\u8a00\u677f\u300d\u793a\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/102036.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-09-07T19:42:56+00:00\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/102036.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/102036.html\",\"name\":\"\u4e00\u6587\u638c\u63e1 jQuery + Flask \u5168\u6808\u6838\u5fc3\u77e5\u8bc6\u70b9\uff08\u524d\u7aef\u4ea4\u4e92 + \u540e\u7aef\u63a5\u53e3 + \u524d\u540e\u7aef\u8054\u8c03\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-09-07T19:42:56+00:00\",\"dateModified\":\"2026-09-07T19:42:56+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/102036.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/102036.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/102036.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u4e00\u6587\u638c\u63e1 jQuery + Flask \u5168\u6808\u6838\u5fc3\u77e5\u8bc6\u70b9\uff08\u524d\u7aef\u4ea4\u4e92 + \u540e\u7aef\u63a5\u53e3 + \u524d\u540e\u7aef\u8054\u8c03\uff09\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"\u4e00\u6587\u638c\u63e1 jQuery + Flask \u5168\u6808\u6838\u5fc3\u77e5\u8bc6\u70b9\uff08\u524d\u7aef\u4ea4\u4e92 + \u540e\u7aef\u63a5\u53e3 + \u524d\u540e\u7aef\u8054\u8c03\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/102036.html","og_locale":"zh_CN","og_type":"article","og_title":"\u4e00\u6587\u638c\u63e1 jQuery + Flask \u5168\u6808\u6838\u5fc3\u77e5\u8bc6\u70b9\uff08\u524d\u7aef\u4ea4\u4e92 + \u540e\u7aef\u63a5\u53e3 + \u524d\u540e\u7aef\u8054\u8c03\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u524d\u8a00\u505a Web \u5f00\u53d1&#xff0c;\u672c\u8d28\u4e0a\u662f\u524d\u7aef \u540e\u7aef\u4e24\u534a&#xff1a;\u524d\u7aef\u8d1f\u8d23\u300c\u7528\u6237\u770b\u5230\u4ec0\u4e48\u3001\u70b9\u4e86\u6709\u4ec0\u4e48\u53cd\u5e94\u300d&#xff0c;\u540e\u7aef\u8d1f\u8d23\u300c\u6570\u636e\u4ece\u54ea\u6765\u3001\u5b58\u5230\u54ea\u53bb\u300d\u3002\u524d\u7aef&#xff1a;\u7528 jQuery \u505a\u4ea4\u4e92 \u2014\u2014 \u9009\u5143\u7d20\u3001\u6539\u5185\u5bb9\u3001\u7ed1\u4e8b\u4ef6\u3001\u53d1\u8bf7\u6c42\u3002\u540e\u7aef&#xff1a;\u7528 Flask \u505a\u63a5\u53e3 \u2014\u2014 \u63a5\u8bf7\u6c42\u3001\u5904\u7406\u6570\u636e\u3001\u67e5\u6570\u636e\u5e93\u3001\u8fd4\u56de\u7ed3\u679c\u3002\u672c\u6587\u628a\u8fd9\u4e24\u90e8\u5206\u7684\u6838\u5fc3\u77e5\u8bc6\u70b9\u6574\u5408\u6210\u4e00\u7bc7&#xff0c;\u91cd\u70b9\u8bb2\u6e05\u695a\u524d\u7aef\u53d1\u8bf7\u6c42 \u2194 \u540e\u7aef\u5904\u7406 \u2194 \u8fd4\u56de\u6570\u636e\u8fd9\u6761\u5b8c\u6574\u94fe\u8def\u3002\u8bfb\u5b8c\u5e76\u8dd1\u901a\u6587\u672b\u7684\u300c\u7559\u8a00\u677f\u300d\u793a","og_url":"https:\/\/www.wsisp.com\/helps\/102036.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-09-07T19:42:56+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"5 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/102036.html","url":"https:\/\/www.wsisp.com\/helps\/102036.html","name":"\u4e00\u6587\u638c\u63e1 jQuery + Flask \u5168\u6808\u6838\u5fc3\u77e5\u8bc6\u70b9\uff08\u524d\u7aef\u4ea4\u4e92 + \u540e\u7aef\u63a5\u53e3 + \u524d\u540e\u7aef\u8054\u8c03\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-09-07T19:42:56+00:00","dateModified":"2026-09-07T19:42:56+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/102036.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/102036.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/102036.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u4e00\u6587\u638c\u63e1 jQuery + Flask \u5168\u6808\u6838\u5fc3\u77e5\u8bc6\u70b9\uff08\u524d\u7aef\u4ea4\u4e92 + \u540e\u7aef\u63a5\u53e3 + \u524d\u540e\u7aef\u8054\u8c03\uff09"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/102036","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=102036"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/102036\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=102036"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=102036"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=102036"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=102036"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}