{"id":84877,"date":"2026-07-26T19:40:40","date_gmt":"2026-07-26T11:40:40","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/84877.html"},"modified":"2026-07-26T19:40:40","modified_gmt":"2026-07-26T11:40:40","slug":"%e9%9d%a2%e5%90%910%e5%9f%ba%e7%a1%80%e7%9a%84fastapi%e6%95%99%e7%a8%8b%ef%bc%9a7-%e9%83%a8%e7%bd%b2%e4%b8%8a%e7%ba%bf-%e8%ae%a9%e7%b3%bb%e7%bb%9f-%e8%b7%91%e5%9c%a8","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/84877.html","title":{"rendered":"\u9762\u54110\u57fa\u7840\u7684FastAPI\u6559\u7a0b\uff1a7.\u90e8\u7f72\u4e0a\u7ebf \u2014\u2014 \u8ba9\u7cfb\u7edf \u201c\u8dd1\u5728\u670d\u52a1\u5668\u4e0a\u201d"},"content":{"rendered":"<p>\u524d\u9762\u4e03\u7bc7\u6211\u4eec\u5b8c\u6210\u4e86\u5f00\u53d1\u9636\u6bb5\u7684\u6240\u6709\u5de5\u4f5c&#xff1a;\u63a5\u53e3\u5199\u597d\u4e86\u3001\u8ba4\u8bc1\u505a\u4e86\u3001\u65e5\u5fd7\u548c\u6d4b\u8bd5\u4e5f\u6709\u4e86\u3002\u73b0\u5728\u8981\u8fdb\u5165\u90e8\u7f72\u9636\u6bb5\u2014\u2014 \u628a\u4ee3\u7801\u4ece\u672c\u5730\u7535\u8111\u642c\u5230\u670d\u52a1\u5668\u4e0a&#xff0c;\u8ba9\u522b\u4eba\u80fd\u901a\u8fc7\u57df\u540d\u8bbf\u95ee\u4f60\u7684\u7cfb\u7edf&#xff08;\u6bd4\u5982https:\/\/your-domain.com&#xff09;\u3002<\/p>\n<h3>\u4e00\u3001\u5148\u641e\u61c2&#xff1a;\u4f01\u4e1a\u7ea7\u90e8\u7f72\u9700\u8981\u4ec0\u4e48&#xff1f;<\/h3>\n<p>\u60f3\u8c61\u4e00\u4e0b&#xff1a;\u4f60\u5f00\u4e86\u5bb6\u5976\u8336\u5e97&#xff0c;\u672c\u5730\u7814\u53d1\u4e86 \u201c\u5976\u8336\u914d\u65b9\u201d&#xff08;\u4ee3\u7801&#xff09;&#xff0c;\u73b0\u5728\u8981\u5f00\u5206\u5e97&#xff08;\u670d\u52a1\u5668&#xff09;\u2014\u2014 \u4f60\u9700\u8981&#xff1a;<\/p>\n<li>\u7edf\u4e00\u7684\u73af\u5883&#xff1a;\u5206\u5e97\u7684\u53a8\u623f\u8bbe\u5907&#xff08;\u670d\u52a1\u5668\u73af\u5883&#xff09;\u8981\u548c\u7814\u53d1\u65f6\u4e00\u6837&#xff0c;\u5426\u5219\u505a\u51fa\u6765\u7684\u5976\u8336\u5473\u9053\u4e0d\u5bf9&#xff08;\u4ee3\u7801\u8fd0\u884c\u62a5\u9519&#xff09;&#xff1b;<\/li>\n<li>\u7a33\u5b9a\u7684 \u201c\u51fa\u9910\u53f0\u201d&#xff1a;\u987e\u5ba2\u6765\u4e86\u8981\u5feb\u901f\u62ff\u5230\u5976\u8336&#xff08;\u63a5\u53e3\u54cd\u5e94\u5feb&#xff09;&#xff1b;<\/li>\n<li>\u5b89\u5168\u7684 \u201c\u95e8\u201d&#xff1a;\u9632\u6b62\u574f\u4eba\u5077\u914d\u65b9&#xff08;HTTPS \u52a0\u5bc6&#xff09;&#xff1b;<\/li>\n<li>\u201c\u524d\u53f0\u63a5\u5f85\u201d&#xff1a;\u5f15\u5bfc\u987e\u5ba2\u5230\u6b63\u786e\u7684\u7a97\u53e3&#xff08;Nginx \u53cd\u5411\u4ee3\u7406&#xff09;\u3002<\/li>\n<p>\u5bf9\u5e94\u5230\u6280\u672f\u4e0a&#xff0c;\u4f01\u4e1a\u7ea7\u90e8\u7f72\u7684\u6838\u5fc3\u7ec4\u4ef6\u662f&#xff1a;<\/p>\n<ul>\n<li>Docker&#xff1a;\u6253\u5305\u5e94\u7528\u548c\u73af\u5883&#xff0c;\u786e\u4fdd \u201c\u4e00\u6b21\u6784\u5efa&#xff0c;\u5230\u5904\u8fd0\u884c\u201d&#xff1b;<\/li>\n<li>Uvicorn&#xff1a;FastAPI \u7684\u5b98\u65b9 ASGI \u670d\u52a1\u5668&#xff08;\u5904\u7406\u9ad8\u5e76\u53d1\u8bf7\u6c42&#xff09;&#xff1b;<\/li>\n<li>Nginx&#xff1a;\u53cd\u5411\u4ee3\u7406&#xff08;\u5904\u7406\u9759\u6001\u6587\u4ef6\u3001\u8d1f\u8f7d\u5747\u8861\u3001HTTPS&#xff09;&#xff1b;<\/li>\n<li>SSL \u8bc1\u4e66&#xff1a;\u8ba9\u63a5\u53e3\u7528 HTTPS&#xff0c;\u52a0\u5bc6\u4f20\u8f93\u6570\u636e\u3002<\/li>\n<\/ul>\n<h3>\u4e8c\u3001\u90e8\u7f72\u524d\u7684\u51c6\u5907<\/h3>\n<h4>1. \u670d\u52a1\u5668\u51c6\u5907<\/h4>\n<ul>\n<li>\u4e70\u4e00\u53f0\u4e91\u670d\u52a1\u5668&#xff08;\u6bd4\u5982\u963f\u91cc\u4e91\u3001\u817e\u8baf\u4e91&#xff0c;\u9009 Ubuntu 22.04 \u7cfb\u7edf&#xff0c;2 \u6838 4G \u8db3\u591f\u8d77\u6b65&#xff09;&#xff1b;<\/li>\n<li>\u57df\u540d&#xff08;\u6bd4\u5982your-domain.com&#xff0c;\u963f\u91cc\u4e91 \/ \u817e\u8baf\u4e91\u53ef\u4ee5\u4e70&#xff0c;\u7136\u540e\u89e3\u6790\u5230\u670d\u52a1\u5668 IP&#xff09;\u3002<\/li>\n<\/ul>\n<h4>2. \u5b89\u88c5 Docker \u548c Docker Compose<\/h4>\n<p>Docker \u662f \u201c\u96c6\u88c5\u7bb1\u201d&#xff0c;\u628a\u5e94\u7528\u548c\u4f9d\u8d56\u6253\u5305\u5728\u4e00\u8d77&#xff1b;Docker Compose \u662f \u201c\u96c6\u88c5\u7bb1\u7ba1\u7406\u5668\u201d&#xff0c;\u7ba1\u7406\u591a\u4e2a\u5bb9\u5668&#xff08;\u6bd4\u5982 FastAPI\u3001MySQL\u3001Redis&#xff09;\u3002<\/p>\n<h5>&#xff08;1&#xff09;\u5b89\u88c5 Docker&#xff08;Ubuntu \u7cfb\u7edf&#xff09;<\/h5>\n<p># \u66f4\u65b0\u8f6f\u4ef6\u6e90<br \/>\nsudo apt update<br \/>\n# \u5b89\u88c5\u4f9d\u8d56<br \/>\nsudo apt install -y apt-transport-https ca-certificates curl software-properties-common<br \/>\n# \u6dfb\u52a0Docker\u7684GPG\u5bc6\u94a5<br \/>\ncurl -fsSL https:\/\/download.docker.com\/linux\/ubuntu\/gpg | sudo gpg &#8211;dearmor -o \/usr\/share\/keyrings\/docker-archive-keyring.gpg<br \/>\n# \u6dfb\u52a0Docker\u8f6f\u4ef6\u6e90<br \/>\necho &#034;deb [arch&#061;$(dpkg &#8211;print-architecture) signed-by&#061;\/usr\/share\/keyrings\/docker-archive-keyring.gpg] https:\/\/download.docker.com\/linux\/ubuntu $(lsb_release -cs) stable&#034; | sudo tee \/etc\/apt\/sources.list.d\/docker.list &gt; \/dev\/null<br \/>\n# \u5b89\u88c5Docker<br \/>\nsudo apt update<br \/>\nsudo apt install -y docker-ce docker-ce-cli containerd.io<br \/>\n# \u9a8c\u8bc1Docker\u662f\u5426\u5b89\u88c5\u6210\u529f&#xff08;\u8f93\u51faDocker\u7248\u672c&#xff09;<br \/>\ndocker &#8211;version<\/p>\n<h5>&#xff08;2&#xff09;\u5b89\u88c5 Docker Compose<\/h5>\n<p># \u4e0b\u8f7dDocker Compose&#xff08;\u7248\u672c\u53f7\u53ef\u4ee5\u6362\u6700\u65b0\u7684&#xff0c;\u770bhttps:\/\/github.com\/docker\/compose\/releases&#xff09;<br \/>\nsudo curl -L &#034;https:\/\/github.com\/docker\/compose\/releases\/download\/v2.27.0\/docker-compose-$(uname -s)-$(uname -m)&#034; -o \/usr\/local\/bin\/docker-compose<br \/>\n# \u7ed9\u6267\u884c\u6743\u9650<br \/>\nsudo chmod &#043;x \/usr\/local\/bin\/docker-compose<br \/>\n# \u9a8c\u8bc1&#xff08;\u8f93\u51fa\u7248\u672c\u53f7&#xff09;<br \/>\ndocker-compose &#8211;version<\/p>\n<h3>\u4e09\u3001\u6253\u5305 FastAPI \u5e94\u7528\u4e3a Docker \u955c\u50cf<\/h3>\n<h4>1. \u7f16\u5199 Dockerfile&#xff08;\u6838\u5fc3\u914d\u7f6e&#xff09;<\/h4>\n<p>Dockerfile \u662f \u201c\u96c6\u88c5\u7bb1\u7684\u5efa\u9020\u8bf4\u660e\u4e66\u201d&#xff0c;\u544a\u8bc9 Docker \u600e\u4e48\u6253\u5305\u4f60\u7684\u5e94\u7528\u3002\u5728\u9879\u76ee\u6839\u76ee\u5f55\u521b\u5efaDockerfile&#xff1a;<\/p>\n<p># \u7b2c\u4e00\u9636\u6bb5&#xff1a;\u6784\u5efa\u4f9d\u8d56&#xff08;\u7528Python 3.11\u7684\u5b98\u65b9\u955c\u50cf&#xff0c;\u4f53\u79ef\u5c0f&#xff09;<br \/>\nFROM python:3.11-slim AS builder<\/p>\n<p># \u8bbe\u7f6e\u5de5\u4f5c\u76ee\u5f55<br \/>\nWORKDIR \/app<\/p>\n<p># \u5b89\u88c5\u7cfb\u7edf\u4f9d\u8d56&#xff08;\u6bd4\u5982gcc&#xff0c;\u7528\u4e8e\u7f16\u8bd1Python\u5305&#xff09;<br \/>\nRUN apt update &amp;&amp; apt install -y &#8211;no-install-recommends gcc python3-dev libpq-dev<\/p>\n<p># \u590d\u5236 requirements.txt \u5230\u5bb9\u5668<br \/>\nCOPY requirements.txt .<\/p>\n<p># \u5b89\u88c5Python\u4f9d\u8d56\u5230venv&#xff08;\u865a\u62df\u73af\u5883&#xff0c;\u51cf\u5c11\u955c\u50cf\u4f53\u79ef&#xff09;<br \/>\nRUN python -m venv \/venv<br \/>\nRUN \/venv\/bin\/pip install &#8211;upgrade pip<br \/>\nRUN \/venv\/bin\/pip install -r requirements.txt &#8211;no-cache-dir<\/p>\n<p># \u7b2c\u4e8c\u9636\u6bb5&#xff1a;\u8fd0\u884c\u5e94\u7528&#xff08;\u7528\u66f4\u8f7b\u7684\u955c\u50cf&#xff0c;\u4f53\u79ef\u66f4\u5c0f&#xff09;<br \/>\nFROM python:3.11-slim AS runner<\/p>\n<p># \u8bbe\u7f6e\u5de5\u4f5c\u76ee\u5f55<br \/>\nWORKDIR \/app<\/p>\n<p># \u4ece\u7b2c\u4e00\u9636\u6bb5\u590d\u5236venv\u548c\u4ee3\u7801<br \/>\nCOPY &#8211;from&#061;builder \/venv \/venv<br \/>\nCOPY . .<\/p>\n<p># \u8bbe\u7f6e\u73af\u5883\u53d8\u91cf&#xff08;\u544a\u8bc9FastAPI\u7528\u751f\u4ea7\u6a21\u5f0f&#xff09;<br \/>\nENV PYTHONUNBUFFERED&#061;1 \\\\<br \/>\n    PYTHONDONTWRITEBYTECODE&#061;1 \\\\<br \/>\n    PATH&#061;&#034;\/venv\/bin:$PATH&#034;<\/p>\n<p># \u66b4\u9732\u7aef\u53e3&#xff08;FastAPI\u8fd0\u884c\u57288000\u7aef\u53e3&#xff09;<br \/>\nEXPOSE 8000<\/p>\n<p># \u542f\u52a8\u547d\u4ee4&#xff08;\u7528Uvicorn\u8fd0\u884cFastAPI&#xff0c;\u914d\u7f6e\u751f\u4ea7\u53c2\u6570&#xff09;<br \/>\nCMD [&#034;uvicorn&#034;, &#034;main:app&#034;, &#034;&#8211;host&#034;, &#034;0.0.0.0&#034;, &#034;&#8211;port&#034;, &#034;8000&#034;, &#034;&#8211;workers&#034;, &#034;4&#034;, &#034;&#8211;proxy-headers&#034;, &#034;&#8211;forwarded-allow-ips&#034;, &#034;*&#034;]<\/p>\n<h4>2. \u5173\u952e\u914d\u7f6e\u89e3\u91ca<\/h4>\n<ul>\n<li>\u591a\u9636\u6bb5\u6784\u5efa&#xff1a;\u7b2c\u4e00\u9636\u6bb5&#xff08;builder&#xff09;\u5b89\u88c5\u4f9d\u8d56&#xff0c;\u7b2c\u4e8c\u9636\u6bb5&#xff08;runner&#xff09;\u53ea\u590d\u5236\u9700\u8981\u7684\u6587\u4ef6&#xff08;venv \u548c\u4ee3\u7801&#xff09;\u2014\u2014 \u8fd9\u6837\u955c\u50cf\u4f53\u79ef\u80fd\u4ece\u51e0\u767e MB \u7f29\u5c0f\u5230\u51e0\u5341 MB&#xff1b;<\/li>\n<li>\u865a\u62df\u73af\u5883&#xff08;venv&#xff09;&#xff1a;\u9694\u79bb Python \u4f9d\u8d56&#xff0c;\u907f\u514d\u548c\u7cfb\u7edf Python \u51b2\u7a81&#xff1b;<\/li>\n<li>Uvicorn \u53c2\u6570&#xff1a;\n<ul>\n<li>&#8211;workers 4&#xff1a;\u542f\u52a8 4 \u4e2a\u5de5\u4f5c\u8fdb\u7a0b&#xff08;\u6839\u636e\u670d\u52a1\u5668 CPU \u6838\u5fc3\u6570\u8c03\u6574&#xff0c;\u6bd4\u5982 2 \u6838\u7528 2&#xff0c;4 \u6838\u7528 4&#xff09;&#xff1b;<\/li>\n<li>&#8211;proxy-headers&#xff1a;\u8ba9 Uvicorn \u4fe1\u4efb Nginx \u7684\u4ee3\u7406\u5934&#xff08;\u6bd4\u5982\u771f\u5b9e IP&#xff09;&#xff1b;<\/li>\n<li>&#8211;forwarded-allow-ips &#034;*&#034;&#xff1a;\u5141\u8bb8\u6240\u6709 IP \u7684\u4ee3\u7406&#xff08;\u751f\u4ea7\u73af\u5883\u53ef\u4ee5\u9650\u5236\u4e3a Nginx \u7684 IP&#xff09;\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h4>3. \u7f16\u5199 docker-compose.yml&#xff08;\u7ba1\u7406\u591a\u5bb9\u5668&#xff09;<\/h4>\n<p>\u5982\u679c\u4f60\u7684\u7cfb\u7edf\u4f9d\u8d56MySQL\u6216Redis&#xff08;\u6bd4\u5982\u7f13\u5b58&#xff09;&#xff0c;\u53ef\u4ee5\u7528docker-compose\u4e00\u8d77\u7ba1\u7406\u3002\u521b\u5efadocker-compose.yml&#xff1a;<\/p>\n<p>version: &#034;3.8&#034;<\/p>\n<p>services:<br \/>\n  # FastAPI\u5e94\u7528\u5bb9\u5668<br \/>\n  fastapi-app:<br \/>\n    build: .  # \u7528\u5f53\u524d\u76ee\u5f55\u7684Dockerfile\u6784\u5efa\u955c\u50cf<br \/>\n    container_name: fastapi-app<br \/>\n    restart: always  # \u5bb9\u5668\u6302\u4e86\u81ea\u52a8\u91cd\u542f<br \/>\n    ports:<br \/>\n      &#8211; &#034;8000:8000&#034;  # \u670d\u52a1\u56688000\u7aef\u53e3\u6620\u5c04\u5230\u5bb9\u56688000\u7aef\u53e3<br \/>\n    environment:<br \/>\n      &#8211; DATABASE_URL&#061;mysql&#043;pymysql:\/\/root:your-db-password&#064;mysql:3306\/fastapi_perm_db  # \u6570\u636e\u5e93\u8fde\u63a5&#xff08;mysql\u662f\u5bb9\u5668\u540d&#xff09;<br \/>\n      &#8211; JWT_SECRET_KEY&#061;your-jwt-secret-key<br \/>\n    depends_on:<br \/>\n      &#8211; mysql  # \u5148\u542f\u52a8MySQL\u518d\u542f\u52a8FastAPI<\/p>\n<p>  # MySQL\u6570\u636e\u5e93\u5bb9\u5668<br \/>\n  mysql:<br \/>\n    image: mysql:8.0<br \/>\n    container_name: mysql<br \/>\n    restart: always<br \/>\n    environment:<br \/>\n      &#8211; MYSQL_ROOT_PASSWORD&#061;your-db-password  # \u6839\u5bc6\u7801<br \/>\n      &#8211; MYSQL_DATABASE&#061;fastapi_perm_db  # \u81ea\u52a8\u521b\u5efa\u6570\u636e\u5e93<br \/>\n    volumes:<br \/>\n      &#8211; mysql-data:\/var\/lib\/mysql  # \u6570\u636e\u6301\u4e45\u5316&#xff08;\u5bb9\u5668\u5220\u4e86\u6570\u636e\u4e0d\u4e22&#xff09;<br \/>\n    ports:<br \/>\n      &#8211; &#034;3306:3306&#034;  # \u670d\u52a1\u56683306\u7aef\u53e3\u6620\u5c04\u5230\u5bb9\u56683306\u7aef\u53e3&#xff08;\u53ef\u9009&#xff0c;\u65b9\u4fbf\u672c\u5730\u8fde\u63a5&#xff09;<\/p>\n<p>volumes:<br \/>\n  mysql-data:  # \u6301\u4e45\u5316MySQL\u6570\u636e\u7684\u5377<\/p>\n<h3>\u56db\u3001\u670d\u52a1\u5668\u90e8\u7f72\u64cd\u4f5c<\/h3>\n<h4>1. \u4e0a\u4f20\u4ee3\u7801\u5230\u670d\u52a1\u5668<\/h4>\n<p>\u7528git\u6216scp\u628a\u4ee3\u7801\u4f20\u5230\u670d\u52a1\u5668&#xff08;\u6bd4\u5982\u7528git clone https:\/\/github.com\/yourname\/fastapi-perm-system.git&#xff09;\u3002<\/p>\n<h4>2. \u6784\u5efa\u5e76\u542f\u52a8\u5bb9\u5668<\/h4>\n<p>\u5728\u670d\u52a1\u5668\u7684\u9879\u76ee\u6839\u76ee\u5f55\u8fd0\u884c&#xff1a;<\/p>\n<p># \u6784\u5efa\u955c\u50cf\u5e76\u542f\u52a8\u5bb9\u5668&#xff08;-d\u8868\u793a\u540e\u53f0\u8fd0\u884c&#xff09;<br \/>\ndocker-compose up -d &#8211;build<\/p>\n<h4>3. \u9a8c\u8bc1\u5bb9\u5668\u662f\u5426\u8fd0\u884c<\/h4>\n<p># \u67e5\u770b\u5bb9\u5668\u72b6\u6001&#xff08;\u5e94\u8be5\u90fd\u662fup&#xff09;<br \/>\ndocker-compose ps<\/p>\n<p># \u67e5\u770bFastAPI\u65e5\u5fd7&#xff08;\u6709\u6ca1\u6709\u62a5\u9519&#xff09;<br \/>\ndocker logs -f fastapi-app<\/p>\n<h3>\u4e94\u3001\u914d\u7f6e Nginx&#xff1a;\u505a \u201c\u53cd\u5411\u4ee3\u7406\u201d \u548c \u201cHTTPS\u201d<\/h3>\n<p>\u73b0\u5728 FastAPI \u8fd0\u884c\u5728\u670d\u52a1\u5668\u76848000\u7aef\u53e3&#xff08;\u6bd4\u5982http:\/\/your-server-ip:8000&#xff09;&#xff0c;\u4f46\u7528\u6237\u4e60\u60ef\u7528http:\/\/your-domain.com&#xff08;80 \u7aef\u53e3&#xff09;\u6216https:\/\/your-domain.com&#xff08;443 \u7aef\u53e3&#xff09;\u8bbf\u95ee \u2014\u2014 \u8fd9\u9700\u8981Nginx\u505a \u201c\u53cd\u5411\u4ee3\u7406\u201d&#xff1a;\u628a\u7528\u6237\u7684\u8bf7\u6c42\u8f6c\u53d1\u7ed9 FastAPI \u5bb9\u5668\u3002<\/p>\n<h4>1. \u5b89\u88c5 Nginx<\/h4>\n<p>sudo apt update<br \/>\nsudo apt install -y nginx<\/p>\n<h4>2. \u7f16\u5199 Nginx \u914d\u7f6e\u6587\u4ef6<\/h4>\n<p>\u521b\u5efa\/etc\/nginx\/conf.d\/fastapi.conf&#xff08;\u66ff\u6362your-domain.com\u4e3a\u4f60\u7684\u57df\u540d&#xff09;&#xff1a;<\/p>\n<p>server {<br \/>\n    listen 80;  # \u76d1\u542c80\u7aef\u53e3&#xff08;HTTP&#xff09;<br \/>\n    server_name your-domain.com www.your-domain.com;  # \u4f60\u7684\u57df\u540d<\/p>\n<p>    # \u628a\u6240\u6709HTTP\u8bf7\u6c42\u8f6c\u53d1\u5230HTTPS<br \/>\n    return 301 https:\/\/$host$request_uri;<br \/>\n}<\/p>\n<p>server {<br \/>\n    listen 443 ssl;  # \u76d1\u542c443\u7aef\u53e3&#xff08;HTTPS&#xff09;<br \/>\n    server_name your-domain.com www.your-domain.com;<\/p>\n<p>    # SSL\u8bc1\u4e66\u914d\u7f6e&#xff08;\u540e\u9762\u7528certbot\u81ea\u52a8\u751f\u6210&#xff09;<br \/>\n    ssl_certificate \/etc\/letsencrypt\/live\/your-domain.com\/fullchain.pem;<br \/>\n    ssl_certificate_key \/etc\/letsencrypt\/live\/your-domain.com\/privkey.pem;<br \/>\n    include \/etc\/letsencrypt\/options-ssl-nginx.conf;<br \/>\n    ssl_dhparam \/etc\/letsencrypt\/ssl-dhparams.pem;<\/p>\n<p>    # \u53cd\u5411\u4ee3\u7406\u914d\u7f6e&#xff1a;\u628a\u8bf7\u6c42\u8f6c\u53d1\u7ed9FastAPI\u5bb9\u5668<br \/>\n    location \/ {<br \/>\n        proxy_pass http:\/\/localhost:8000;  # FastAPI\u8fd0\u884c\u5728\u670d\u52a1\u56688000\u7aef\u53e3<br \/>\n        proxy_set_header Host $host;<br \/>\n        proxy_set_header X-Real-IP $remote_addr;<br \/>\n        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;<br \/>\n        proxy_set_header X-Forwarded-Proto $scheme;  # \u544a\u8bc9FastAPI\u7528\u7684\u662fHTTPS<br \/>\n    }<\/p>\n<p>    # \u9759\u6001\u6587\u4ef6\u914d\u7f6e&#xff08;\u5982\u679c\u6709\u524d\u7aef\u9759\u6001\u6587\u4ef6&#xff0c;\u6bd4\u5982Vue\/React\u6253\u5305\u540e\u7684dist&#xff09;<br \/>\n    # location \/static\/ {<br \/>\n    #     root \/path\/to\/your\/static\/files;<br \/>\n    #     expires 30d;  # \u9759\u6001\u6587\u4ef6\u7f13\u5b5830\u5929<br \/>\n    # }<br \/>\n}<\/p>\n<h4>3. \u7533\u8bf7 SSL \u8bc1\u4e66&#xff08;HTTPS&#xff09;<\/h4>\n<p>\u7528Let&#039;s Encrypt&#xff08;\u514d\u8d39\u8bc1\u4e66&#xff09;\u7ed9\u57df\u540d\u52a0 HTTPS&#xff1a;<\/p>\n<p># \u5b89\u88c5certbot&#xff08;Let&#039;s Encrypt\u7684\u5ba2\u6237\u7aef&#xff09;<br \/>\nsudo apt install certbot python3-certbot-nginx<\/p>\n<p># \u7533\u8bf7\u8bc1\u4e66&#xff08;\u81ea\u52a8\u914d\u7f6eNginx&#xff09;<br \/>\nsudo certbot &#8211;nginx -d your-domain.com -d www.your-domain.com<\/p>\n<h4>4. \u9a8c\u8bc1 Nginx \u914d\u7f6e<\/h4>\n<p># \u68c0\u67e5Nginx\u914d\u7f6e\u662f\u5426\u6b63\u786e<br \/>\nsudo nginx -t<\/p>\n<p># \u91cd\u542fNginx\u751f\u6548<br \/>\nsudo systemctl restart nginx<\/p>\n<h3>\u516d\u3001\u6700\u7ec8\u9a8c\u8bc1&#xff1a;\u8bbf\u95ee\u4f60\u7684\u7cfb\u7edf<\/h3>\n<p>\u73b0\u5728&#xff0c;\u6253\u5f00\u6d4f\u89c8\u5668\u8f93\u5165\u4f60\u7684\u57df\u540d&#xff08;\u6bd4\u5982https:\/\/your-domain.com&#xff09;&#xff1a;<\/p>\n<li>\u8bbf\u95ee Swagger \u6587\u6863&#xff1a;https:\/\/your-domain.com\/docs\u2014\u2014 \u80fd\u6253\u5f00\u8bf4\u660e FastAPI \u8fd0\u884c\u6b63\u5e38&#xff1b;<\/li>\n<li>\u6d4b\u8bd5\u63a5\u53e3&#xff1a;\u7528 Swagger \u8c03\u7528\/api\/auth\/login\u63a5\u53e3&#xff0c;\u83b7\u53d6 Token \u540e\u8c03\u7528\/api\/users\u2014\u2014 \u80fd\u8fd4\u56de\u7528\u6237\u5217\u8868\u8bf4\u660e\u63a5\u53e3\u6b63\u5e38&#xff1b;<\/li>\n<li>\u68c0\u67e5 HTTPS&#xff1a;\u6d4f\u89c8\u5668\u5730\u5740\u680f\u6709 \u201c\u5c0f\u9501\u201d \u56fe\u6807&#xff0c;\u70b9\u51fb\u80fd\u770b\u5230\u8bc1\u4e66\u4fe1\u606f \u2014\u2014 \u8bf4\u660e HTTPS \u914d\u7f6e\u6210\u529f\u3002<\/li>\n<h3>\u4e03\u3001\u5e38\u89c1\u95ee\u9898\u6392\u67e5<\/h3>\n<h4>1. \u5bb9\u5668\u542f\u52a8\u5931\u8d25&#xff08;docker-compose ps \u663e\u793a exited&#xff09;<\/h4>\n<ul>\n<li>\u539f\u56e0&#xff1a;\u73af\u5883\u53d8\u91cf\u9519\u8bef&#xff08;\u6bd4\u5982DATABASE_URL\u7684\u5bc6\u7801\u4e0d\u5bf9&#xff09;&#xff0c;\u6216\u7aef\u53e3\u88ab\u5360\u7528&#xff1b;<\/li>\n<li>\u89e3\u51b3&#xff1a;\n<li>\u770b\u65e5\u5fd7&#xff1a;docker logs -f fastapi-app&#xff0c;\u627e\u9519\u8bef\u539f\u56e0&#xff08;\u6bd4\u5982 \u201cCan&#039;t connect to MySQL\u201d&#xff09;&#xff1b;<\/li>\n<li>\u68c0\u67e5docker-compose.yml\u7684environment\u914d\u7f6e&#xff08;\u6bd4\u5982MYSQL_ROOT_PASSWORD\u662f\u5426\u548cDATABASE_URL\u4e00\u81f4&#xff09;\u3002<\/li>\n<\/li>\n<\/ul>\n<h4>2. \u57df\u540d\u8bbf\u95ee\u4e0d\u4e86&#xff08;\u663e\u793a \u201c\u65e0\u6cd5\u8bbf\u95ee\u6b64\u7f51\u7ad9\u201d&#xff09;<\/h4>\n<ul>\n<li>\u539f\u56e0&#xff1a;\u670d\u52a1\u5668\u9632\u706b\u5899\u6ca1\u5f00 80\/443 \u7aef\u53e3&#xff0c;\u6216\u57df\u540d\u6ca1\u89e3\u6790\u5230\u670d\u52a1\u5668 IP&#xff1b;<\/li>\n<li>\u89e3\u51b3&#xff1a;\n<li>\u68c0\u67e5\u9632\u706b\u5899&#xff1a;sudo ufw allow 80\/tcp&#xff08;\u5141\u8bb8 HTTP&#xff09;\u3001sudo ufw allow 443\/tcp&#xff08;\u5141\u8bb8 HTTPS&#xff09;&#xff1b;<\/li>\n<li>\u68c0\u67e5\u57df\u540d\u89e3\u6790&#xff1a;\u7528ping your-domain.com\u770b\u662f\u5426\u6307\u5411\u670d\u52a1\u5668 IP\u3002<\/li>\n<\/li>\n<\/ul>\n<h4>3. \u63a5\u53e3\u8fd4\u56de \u201c502 Bad Gateway\u201d<\/h4>\n<ul>\n<li>\u539f\u56e0&#xff1a;Nginx \u627e\u4e0d\u5230 FastAPI \u5bb9\u5668&#xff08;\u6bd4\u5982 FastAPI \u6302\u4e86&#xff0c;\u6216\u7aef\u53e3\u6620\u5c04\u9519\u8bef&#xff09;&#xff1b;<\/li>\n<li>\u89e3\u51b3&#xff1a;\n<li>\u68c0\u67e5 FastAPI \u5bb9\u5668\u72b6\u6001&#xff1a;docker-compose ps\u2014\u2014 \u5982\u679c\u662f exited&#xff0c;\u91cd\u542f\u5bb9\u5668&#xff1a;docker-compose restart fastapi-app&#xff1b;<\/li>\n<li>\u68c0\u67e5 Nginx \u914d\u7f6e\u7684proxy_pass\u662f\u5426\u6b63\u786e&#xff08;\u6bd4\u5982http:\/\/localhost:8000\u662f\u5426\u548c FastAPI \u7684\u7aef\u53e3\u4e00\u81f4&#xff09;\u3002<\/li>\n<\/li>\n<\/ul>\n<h3>\u516b\u3001\u603b\u7ed3&#xff1a;\u8fd9\u7bc7\u6211\u4eec\u505a\u4e86\u4ec0\u4e48&#xff1f;<\/h3>\n<li>\u6253\u5305\u955c\u50cf&#xff1a;\u7528 Docker \u591a\u9636\u6bb5\u6784\u5efa\u628a FastAPI \u5e94\u7528\u6253\u5305\u6210\u8f7b\u91cf\u955c\u50cf&#xff1b;<\/li>\n<li>\u5bb9\u5668\u7ba1\u7406&#xff1a;\u7528 docker-compose \u7ba1\u7406 FastAPI \u548c MySQL \u5bb9\u5668&#xff0c;\u5b9e\u73b0\u4e00\u952e\u542f\u52a8&#xff1b;<\/li>\n<li>\u53cd\u5411\u4ee3\u7406&#xff1a;\u7528 Nginx \u628a\u7528\u6237\u8bf7\u6c42\u8f6c\u53d1\u7ed9 FastAPI&#xff0c;\u5904\u7406 HTTPS&#xff1b;<\/li>\n<li>\u8bc1\u4e66\u914d\u7f6e&#xff1a;\u7528 Let&#039;s Encrypt \u7ed9\u57df\u540d\u52a0 HTTPS&#xff0c;\u786e\u4fdd\u6570\u636e\u4f20\u8f93\u5b89\u5168&#xff1b;<\/li>\n<li>\u9a8c\u8bc1\u90e8\u7f72&#xff1a;\u901a\u8fc7\u57df\u540d\u8bbf\u95ee\u7cfb\u7edf&#xff0c;\u786e\u8ba4\u63a5\u53e3\u548c HTTPS \u6b63\u5e38\u3002<\/li>\n<h3>\u6700\u540e&#xff1a;\u90e8\u7f72\u540e\u7684 \u201c\u8fd0\u7ef4\u5c0f\u6280\u5de7\u201d<\/h3>\n<li>\u81ea\u52a8\u91cd\u542f\u5bb9\u5668&#xff1a;docker-compose.yml\u7684restart: always\u2014\u2014 \u5bb9\u5668\u6302\u4e86\u81ea\u52a8\u91cd\u542f&#xff1b;<\/li>\n<li>\u65e5\u5fd7\u67e5\u770b&#xff1a;docker logs -f fastapi-app\u2014\u2014 \u5b9e\u65f6\u770b FastAPI \u65e5\u5fd7&#xff1b;<\/li>\n<li>\u8bc1\u4e66\u7eed\u671f&#xff1a;Let&#039;s Encrypt \u8bc1\u4e66\u6709\u6548\u671f 90 \u5929&#xff0c;\u7528sudo certbot renew\u81ea\u52a8\u7eed\u671f&#xff08;\u53ef\u4ee5\u52a0 cron \u5b9a\u65f6\u4efb\u52a1&#xff09;\u3002<\/li>\n<p>\u5230\u8fd9\u91cc&#xff0c;\u6574\u4e2aFastAPI \u4f01\u4e1a\u7ea7\u9879\u76ee\u5b9e\u6218\u7cfb\u5217\u5c31\u7ed3\u675f\u4e86&#xff01;\u4ece \u201cHello World\u201d \u5230 \u201c\u4e0a\u7ebf\u8fd0\u884c\u201d&#xff0c;\u6211\u4eec\u5b8c\u6210\u4e86\u4e00\u4e2a\u5b8c\u6574\u7684\u4f01\u4e1a\u7ea7\u7cfb\u7edf\u5f00\u53d1\u6d41\u7a0b\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u524d\u9762\u4e03\u7bc7\u6211\u4eec\u5b8c\u6210\u4e86\u5f00\u53d1\u9636\u6bb5\u7684\u6240\u6709\u5de5\u4f5c&#xff1a;\u63a5\u53e3\u5199\u597d\u4e86\u3001\u8ba4\u8bc1\u505a\u4e86\u3001\u65e5\u5fd7\u548c\u6d4b\u8bd5\u4e5f\u6709\u4e86\u3002\u73b0\u5728\u8981\u8fdb\u5165\u90e8\u7f72\u9636\u6bb5\u2014\u2014 \u628a\u4ee3\u7801\u4ece\u672c\u5730\u7535\u8111\u642c\u5230\u670d\u52a1\u5668\u4e0a&#xff0c;\u8ba9\u522b\u4eba\u80fd\u901a\u8fc7\u57df\u540d\u8bbf\u95ee\u4f60\u7684\u7cfb\u7edf&#xff08;\u6bd4\u5982https:\/\/your-domain.com&#xff09;\u3002\u4e00\u3001\u5148\u641e\u61c2&#xff1a;\u4f01\u4e1a\u7ea7\u90e8\u7f72\u9700\u8981\u4ec0\u4e48&#xff1f;\u60f3\u8c61\u4e00\u4e0b&#xff1a;\u4f60\u5f00\u4e86\u5bb6\u5976\u8336\u5e97&#xff0c;\u672c\u5730\u7814\u53d1\u4e86 \u201c\u5976\u8336\u914d\u65b9\u201d&#xff08;\u4ee3\u7801&#xff09;&#xff0c;\u73b0\u5728\u8981\u5f00\u5206\u5e97&amp;#x<\/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":[72,114,50,43,44],"topic":[],"class_list":["post-84877","post","type-post","status-publish","format-standard","hentry","category-server","tag-fastapi","tag-mysql","tag-50","tag-43","tag-44"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u9762\u54110\u57fa\u7840\u7684FastAPI\u6559\u7a0b\uff1a7.\u90e8\u7f72\u4e0a\u7ebf \u2014\u2014 \u8ba9\u7cfb\u7edf \u201c\u8dd1\u5728\u670d\u52a1\u5668\u4e0a\u201d - \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\/84877.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u9762\u54110\u57fa\u7840\u7684FastAPI\u6559\u7a0b\uff1a7.\u90e8\u7f72\u4e0a\u7ebf \u2014\u2014 \u8ba9\u7cfb\u7edf \u201c\u8dd1\u5728\u670d\u52a1\u5668\u4e0a\u201d - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u524d\u9762\u4e03\u7bc7\u6211\u4eec\u5b8c\u6210\u4e86\u5f00\u53d1\u9636\u6bb5\u7684\u6240\u6709\u5de5\u4f5c&#xff1a;\u63a5\u53e3\u5199\u597d\u4e86\u3001\u8ba4\u8bc1\u505a\u4e86\u3001\u65e5\u5fd7\u548c\u6d4b\u8bd5\u4e5f\u6709\u4e86\u3002\u73b0\u5728\u8981\u8fdb\u5165\u90e8\u7f72\u9636\u6bb5\u2014\u2014 \u628a\u4ee3\u7801\u4ece\u672c\u5730\u7535\u8111\u642c\u5230\u670d\u52a1\u5668\u4e0a&#xff0c;\u8ba9\u522b\u4eba\u80fd\u901a\u8fc7\u57df\u540d\u8bbf\u95ee\u4f60\u7684\u7cfb\u7edf&#xff08;\u6bd4\u5982https:\/\/your-domain.com&#xff09;\u3002\u4e00\u3001\u5148\u641e\u61c2&#xff1a;\u4f01\u4e1a\u7ea7\u90e8\u7f72\u9700\u8981\u4ec0\u4e48&#xff1f;\u60f3\u8c61\u4e00\u4e0b&#xff1a;\u4f60\u5f00\u4e86\u5bb6\u5976\u8336\u5e97&#xff0c;\u672c\u5730\u7814\u53d1\u4e86 \u201c\u5976\u8336\u914d\u65b9\u201d&#xff08;\u4ee3\u7801&#xff09;&#xff0c;\u73b0\u5728\u8981\u5f00\u5206\u5e97&amp;#x\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/84877.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-07-26T11:40:40+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\/84877.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/84877.html\",\"name\":\"\u9762\u54110\u57fa\u7840\u7684FastAPI\u6559\u7a0b\uff1a7.\u90e8\u7f72\u4e0a\u7ebf \u2014\u2014 \u8ba9\u7cfb\u7edf \u201c\u8dd1\u5728\u670d\u52a1\u5668\u4e0a\u201d - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-07-26T11:40:40+00:00\",\"dateModified\":\"2026-07-26T11:40:40+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/84877.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/84877.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/84877.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u9762\u54110\u57fa\u7840\u7684FastAPI\u6559\u7a0b\uff1a7.\u90e8\u7f72\u4e0a\u7ebf \u2014\u2014 \u8ba9\u7cfb\u7edf \u201c\u8dd1\u5728\u670d\u52a1\u5668\u4e0a\u201d\"}]},{\"@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":"\u9762\u54110\u57fa\u7840\u7684FastAPI\u6559\u7a0b\uff1a7.\u90e8\u7f72\u4e0a\u7ebf \u2014\u2014 \u8ba9\u7cfb\u7edf \u201c\u8dd1\u5728\u670d\u52a1\u5668\u4e0a\u201d - \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\/84877.html","og_locale":"zh_CN","og_type":"article","og_title":"\u9762\u54110\u57fa\u7840\u7684FastAPI\u6559\u7a0b\uff1a7.\u90e8\u7f72\u4e0a\u7ebf \u2014\u2014 \u8ba9\u7cfb\u7edf \u201c\u8dd1\u5728\u670d\u52a1\u5668\u4e0a\u201d - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u524d\u9762\u4e03\u7bc7\u6211\u4eec\u5b8c\u6210\u4e86\u5f00\u53d1\u9636\u6bb5\u7684\u6240\u6709\u5de5\u4f5c&#xff1a;\u63a5\u53e3\u5199\u597d\u4e86\u3001\u8ba4\u8bc1\u505a\u4e86\u3001\u65e5\u5fd7\u548c\u6d4b\u8bd5\u4e5f\u6709\u4e86\u3002\u73b0\u5728\u8981\u8fdb\u5165\u90e8\u7f72\u9636\u6bb5\u2014\u2014 \u628a\u4ee3\u7801\u4ece\u672c\u5730\u7535\u8111\u642c\u5230\u670d\u52a1\u5668\u4e0a&#xff0c;\u8ba9\u522b\u4eba\u80fd\u901a\u8fc7\u57df\u540d\u8bbf\u95ee\u4f60\u7684\u7cfb\u7edf&#xff08;\u6bd4\u5982https:\/\/your-domain.com&#xff09;\u3002\u4e00\u3001\u5148\u641e\u61c2&#xff1a;\u4f01\u4e1a\u7ea7\u90e8\u7f72\u9700\u8981\u4ec0\u4e48&#xff1f;\u60f3\u8c61\u4e00\u4e0b&#xff1a;\u4f60\u5f00\u4e86\u5bb6\u5976\u8336\u5e97&#xff0c;\u672c\u5730\u7814\u53d1\u4e86 \u201c\u5976\u8336\u914d\u65b9\u201d&#xff08;\u4ee3\u7801&#xff09;&#xff0c;\u73b0\u5728\u8981\u5f00\u5206\u5e97&amp;#x","og_url":"https:\/\/www.wsisp.com\/helps\/84877.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-07-26T11:40:40+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\/84877.html","url":"https:\/\/www.wsisp.com\/helps\/84877.html","name":"\u9762\u54110\u57fa\u7840\u7684FastAPI\u6559\u7a0b\uff1a7.\u90e8\u7f72\u4e0a\u7ebf \u2014\u2014 \u8ba9\u7cfb\u7edf \u201c\u8dd1\u5728\u670d\u52a1\u5668\u4e0a\u201d - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-07-26T11:40:40+00:00","dateModified":"2026-07-26T11:40:40+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/84877.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/84877.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/84877.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u9762\u54110\u57fa\u7840\u7684FastAPI\u6559\u7a0b\uff1a7.\u90e8\u7f72\u4e0a\u7ebf \u2014\u2014 \u8ba9\u7cfb\u7edf \u201c\u8dd1\u5728\u670d\u52a1\u5668\u4e0a\u201d"}]},{"@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\/84877","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=84877"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/84877\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=84877"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=84877"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=84877"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=84877"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}