{"id":19666,"date":"2024-03-26T15:42:14","date_gmt":"2024-03-26T07:42:14","guid":{"rendered":"https:\/\/www.yimenyun.cn\/emen\/?p=19666"},"modified":"2024-03-26T15:42:14","modified_gmt":"2024-03-26T07:42:14","slug":"windows%e5%88%9b%e5%bb%baexe%e6%9c%8d%e6%93%8d%e4%bd%9c%e5%8a%9e%e6%b3%95%e4%bb%8b%e7%bb%8d","status":"publish","type":"post","link":"https:\/\/www.yimenyun.cn\/emen\/19666\/","title":{"rendered":"windows\u521b\u5efaexe\u670d\u64cd\u4f5c\u529e\u6cd5\u4ecb\u7ecd"},"content":{"rendered":"

mfc\u5c01\u88c5\u6210exe<\/a> <\/p>\n

\u5728Windows\u4e0a\u521b\u5efa\u4e00\u4e2a\u53ef\u6267\u884c\u6587\u4ef6\uff08exe\uff09\u670d\u52a1\u5668\u662f\u4e00\u4e2a\u76f8\u5bf9\u7b80\u5355\u7684\u8fc7\u7a0b\u3002\u672c\u6587\u5c06\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528Python\u548cFlask\u6846\u67b6\u6765\u521b\u5efa\u4e00\u4e2a\u7b80\u5355\u7684Web\u670d\u52a1\u5668\uff0c\u7136\u540e\u4f7f\u7528PyInstaller\u5c06\u5176\u6253\u5305\u6210\u4e00\u4e2a\u53ef\u6267\u884c\u6587\u4ef6\u3002<\/p>\n

1. \u5b89\u88c5Python\u548cFlask\u6846\u67b6<\/p>\n

\u9996\u5148\u9700\u8981\u5b89\u88c5Python\u548cFlask\u6846\u67b6\u3002Python\u662f\u4e00\u79cd\u901a\u7528\u7684\u7f16\u7a0b\u8bed\u8a00\uff0cFlask\u662f\u4e00\u4e2a\u8f7b\u91cf\u7ea7\u7684Web\u6846\u67b6\u3002\u5b89\u88c5Python\u540e\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u6765\u5b89\u88c5Flask\uff1a<\/p>\n

“`<\/p>\n

pip install flask<\/p>\n

`<\/p>\n

<\/figure>\n<\/p>\n

“<\/p>\n

2. \u521b\u5efa\u4e00\u4e2a\u7b80\u5355\u7684Web\u670d\u52a1\u5668<\/p>\n

\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u5c06\u521b\u5efa\u4e00\u4e2a\u7b80\u5355\u7684Web\u670d\u52a1\u5668\u3002\u5728Python\u4e2d\uff0c\u4f7f\u7528Flask\u6846\u67b6\u53ef\u4ee5\u8f7b\u677e\u5730\u521b\u5efaWeb\u5e94\u7528\u7a0b\u5e8f\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u793a\u4f8b\uff1a<\/p>\n

“`python<\/p>\n

from flask import Flask<\/p>\n

app = Flask(__name__)<\/p>\n

@app.route(‘\/’)<\/p>\n

def hello_world():<\/p>\n

return ‘Hello, World!’<\/p>\n

if __name__ == ‘__main__’:<\/p>\n

app.run()<\/p>\n

“`<\/p>\n

\u6b64\u4ee3\u7801\u5c06\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a\u201capp\u201d\u7684Flask\u5e94\u7528\u7a0b\u5e8f\uff0c\u5e76\u5b9a\u4e49\u4e00\u4e2a\u8def\u7531\uff08`’\/’`\uff09\uff0c\u8be5\u8def\u7531\u5c06\u8fd4\u56de\u201cHello, World!\u201d\u7684\u5b57\u7b26\u4e32\u3002\u6700\u540e\uff0c\u4f7f\u7528`app.run()`\u6765\u8fd0\u884c\u670d\u52a1\u5668\u3002<\/p>\n

3. \u6253\u5305\u6210\u53ef\u6267\u884c\u6587\u4ef6<\/p>\n

\u4f7f\u7528PyInstaller\u53ef\u4ee5\u5c06Python\u5e94\u7528\u7a0b\u5e8f\u6253\u5305\u6210\u4e00\u4e2a\u53ef\u6267\u884c\u6587\u4ef6\u3002PyInstaller\u662f\u4e00\u4e2a\u7528\u4e8e\u5c06Python\u5e94\u7528\u7a0b\u5e8f\u8f6c\u6362\u4e3a\u72ec\u7acb\u53ef\u6267\u884c\u6587\u4ef6\u7684\u5de5\u5177\u3002\u4ee5\u4e0b\u662f\u4f7f\u7528PyInstaller\u5c06Flask\u5e94\u7528\u7a0b\u5e8f\u6253\u5305\u6210\u4e00\u4e2a\u53ef\u6267\u884c\u6587\u4ef6\u7684\u6b65\u9aa4\uff1a<\/p>\n

– \u5b89\u88c5PyInstaller\uff1a<\/p>\n

“`<\/p>\n

pip in\u5c06vue\u9879\u76ee\u6253\u5305\u4e3awindows\u5e94\u7528<\/a>stall pyinstaller<\/p>\n

“`<\/p>\n

– \u6253\u5305\u5e94\u7528\u7a0b\u5e8f\uff1a<\/p>\n

“`<\/p>\n

pyinstaller –onefile app.py<\/p>\n

“`<\/p>\n

\u6b64\u547d\u4ee4\u5c06\u5728\u5f53\u524d\u76ee\u5f55\u4e0b\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a\u201cdist\u201d\u7684\u6587\u4ef6\u5939\uff0c\u5e76\u5728\u5176\u4e2d\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a\u201capp\u201d\u7684\u53ef\u6267\u884c\u6587\u4ef6\u3002<\/p>\n

4. \u8fd0\u884c\u53ef\u6267\u884c\u6587\u4ef6<\/p>\n

\u6700\u540e\uff0c\u53ef\u4ee5\u8fd0\u884c\u751f\u6210\u7684\u53ef\u6267\u884c\u6587\u4ef6\u3002\u5728Windows\u4e0a\uff0c\u53ef\u4ee5\u53cc\u51fb\u53ef\u6267\u884c\u6587\u4ef6\u6216\u5728\u547d\u4ee4\u63d0\u793a\u7b26\u4e2d\u8fd0\u884c\u5b83\uff1a<\/p>\n

“`<\/p>\n

.\\app.exe<\/p>\n

“`<\/p>\n

\u6b64\u547d\u4ee4\u5c06\u542f\u52a8Web\u670d\u52a1\u5668\uff0c\u5e76\u5728\u6d4f\u89c8\u5668\u4e2d\u8bbf\u95ee`http:\/\/localhost:5000`\u4ee5\u67e5\u770b\u201cHello, World!\u201d\u6d88\u606f\u3002<\/p>\n

\u603b\u7ed3<\/p>\n

\u672c\u6587\u4ecb\u7ecd\u4e86\u5982\u4f55\u5728Windows\u4e0a\u521b\u5efa\u4e00\u4e2a\u7b80\u5355\u7684Web\u670d\u52a1\u5668\uff0c\u5e76\u5c06\u5176\u6253\u5305\u6210\u4e00\u4e2a\u53ef\u6267\u884c\u6587\u4ef6\u3002\u4f7f\u7528Python\u548cFlask\u6846\u67b6\u53ef\u4ee5\u8f7b\u677e\u5730\u521b\u5efaWeb\u5e94\u7528\u7a0b\u5e8f\uff0c\u800cPyInstaller\u5219\u53ef\u4ee5\u5c06\u5176\u6253\u5305\u6210\u4e00\u4e2a\u53ef\u6267\u884c\u6587\u4ef6\u3002\u8fd9\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u793a\u4f8b\uff0c\u4f46\u53ef\u4ee5\u4e3a\u60f3\u8981\u521b\u5efa\u81ea\u5df1\u7684Web\u670d\u52a1\u5668\u7684\u4eba\u63d0\u4f9b\u4e00\u4e2a\u5f88\u597d\u7684\u8d77\u70b9\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"

\u5728Windows\u4e0a\u521b\u5efa\u4e00\u4e2a\u53ef\u6267\u884c\u6587\u4ef6\uff08exe\uff09\u670d\u52a1\u5668\u662f\u4e00\u4e2a\u76f8\u5bf9\u7b80\u5355\u7684\u8fc7\u7a0b\u3002\u672c\u6587\u5c06\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528Python\u548cFlask\u6846\u67b6\u6765\u521b\u5efa\u4e00\u4e2a\u7b80\u5355\u7684Web\u670d\u52a1\u5668\uff0c\u7136\u540e\u4f7f\u7528PyInstaller\u5c06\u5176\u6253\u5305\u6210\u4e00\u4e2a\u53ef\u6267<\/p>\n","protected":false},"author":10,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[11574,2325,256,25,7936],"topic":[],"class_list":["post-19666","post","type-post","status-publish","format-standard","hentry","category-exekf","tag-dmg","tag-2325","tag-256","tag-25","tag-exe"],"_links":{"self":[{"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/posts\/19666","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/users\/10"}],"replies":[{"embeddable":true,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/comments?post=19666"}],"version-history":[{"count":1,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/posts\/19666\/revisions"}],"predecessor-version":[{"id":19776,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/posts\/19666\/revisions\/19776"}],"wp:attachment":[{"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/media?parent=19666"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/categories?post=19666"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/tags?post=19666"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/topic?post=19666"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}