7wu1wm0 发表于 2024-7-27 22:18:26

让咱们用 Flask + Python 构建一个美丽简约的网站(附完整源码)


    <div style="color: black; text-align: left; margin-bottom: 10px;"><img src="https://p3-sign.toutiaoimg.com/tos-cn-i-qvj2lq49k0/7d57456e84c448c88fbd30540fee54ed~noop.image?_iz=58558&amp;from=article.pc_detail&amp;lk3s=953192f4&amp;x-expires=1722663615&amp;x-signature=1qfcHP8pXxDR%2BPSbwFX43eYkgTk%3D" style="width: 50%; margin-bottom: 20px;"></div>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">正如大<span style="color: black;">都数</span>人所知,Python 是一种非常棒的编程语言,<span style="color: black;">拥有</span><span style="color: black;">海量</span>的功能,您<span style="color: black;">能够</span><span style="color: black;">运用</span> Python 做的事情之一<span style="color: black;">便是</span><span style="color: black;">研发</span>网站,<span style="color: black;">因此</span>让<span style="color: black;">咱们</span>用 Flask 构建一个简约的网站吧!<span style="color: black;">此刻</span>,这个网站<span style="color: black;">已然</span>完全建成并托管在 GitHub 上,</span><strong style="color: blue;"><span style="color: black;"><span style="color: black;">文案</span>结尾有源码链接<span style="color: black;">位置</span></span></strong><span style="color: black;">。</span></p>
    <h1 style="color: black; text-align: left; margin-bottom: 10px;">源码目录结构</h1>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">源码目录中有几个<span style="color: black;">区别</span>的文件,<span style="color: black;">咱们</span>有一个</span><strong style="color: blue;"><span style="color: black;">截图</span></strong><span style="color: black;">文件夹、一个</span><strong style="color: blue;"><span style="color: black;">静态</span></strong><span style="color: black;">文件夹、一个</span><strong style="color: blue;"><span style="color: black;">模板</span></strong><span style="color: black;">文件夹、一个</span><strong style="color: blue;"><span style="color: black;">自述</span></strong><span style="color: black;">文件、一个</span><strong style="color: blue;"><span style="color: black;">app.py</span></strong><span style="color: black;">文件、一个</span><strong style="color: blue;"><span style="color: black;">requirements.txt</span></strong><span style="color: black;">文件和一个</span><strong style="color: blue;"><span style="color: black;">runtime.txt</span></strong><span style="color: black;">文件:</span></p>
    <div style="color: black; text-align: left; margin-bottom: 10px;"><img src="https://p3-sign.toutiaoimg.com/tos-cn-i-qvj2lq49k0/4d20a94c0b64485b87459dcd9679de59~noop.image?_iz=58558&amp;from=article.pc_detail&amp;lk3s=953192f4&amp;x-expires=1722663615&amp;x-signature=%2BaB4thBF7s2HIX3ehzaPmnZQQsY%3D" style="width: 50%; margin-bottom: 20px;"></div>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">打开</span><strong style="color: blue;"><span style="color: black;">requirements.txt</span></strong><span style="color: black;">文件<span style="color: black;">咱们</span><span style="color: black;">能够</span>看到<span style="color: black;">咱们</span><span style="color: black;">运用</span>了几个包,<span style="color: black;">首要</span>安装所有这些包(您<span style="color: black;">能够</span><span style="color: black;">运用</span> install requirements.txt 函数):</span></p>
    <div style="color: black; text-align: left; margin-bottom: 10px;"><img src="https://p3-sign.toutiaoimg.com/tos-cn-i-qvj2lq49k0/c0f82ffe446c4f93983f153716ec661a~noop.image?_iz=58558&amp;from=article.pc_detail&amp;lk3s=953192f4&amp;x-expires=1722663615&amp;x-signature=HvNw2EFYQlUWCYKfQefW1JMtecI%3D" style="width: 50%; margin-bottom: 20px;"></div>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">在 static 文件夹中,<span style="color: black;">咱们</span>有几个<span style="color: black;">区别</span>的文件夹,这个文件夹存储<span style="color: black;">咱们</span>的 css 文件、字体和<span style="color: black;">有些</span>页面:</span></p>
    <div style="color: black; text-align: left; margin-bottom: 10px;"><img src="https://p3-sign.toutiaoimg.com/tos-cn-i-qvj2lq49k0/eb932c549f5f4ac59dd7c22b9286a6ab~noop.image?_iz=58558&amp;from=article.pc_detail&amp;lk3s=953192f4&amp;x-expires=1722663615&amp;x-signature=Z0eUKRoatSF4y7BvGMxNBFpINIA%3D" style="width: 50%; margin-bottom: 20px;"></div>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">templates 文件夹<span style="color: black;">包括</span><span style="color: black;">咱们</span>所有的 HTML 文件,这些基本上是该网站的所有构建块:</span></p>
    <div style="color: black; text-align: left; margin-bottom: 10px;"><img src="https://p3-sign.toutiaoimg.com/tos-cn-i-qvj2lq49k0/f0af44a70ba2418fa5ae253780a705c3~noop.image?_iz=58558&amp;from=article.pc_detail&amp;lk3s=953192f4&amp;x-expires=1722663615&amp;x-signature=DaAatLJ6BOZRBMjPARhgPpdph3Q%3D" style="width: 50%; margin-bottom: 20px;"></div>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">接下来,app.py 文件有<span style="color: black;">咱们</span>基本的 Flask 后端框架:</span></p>
    <div style="color: black; text-align: left; margin-bottom: 10px;"><img src="https://p3-sign.toutiaoimg.com/tos-cn-i-qvj2lq49k0/c97b95c3a831413f987747a48763e5ee~noop.image?_iz=58558&amp;from=article.pc_detail&amp;lk3s=953192f4&amp;x-expires=1722663615&amp;x-signature=%2B%2Bi8B1JASLBjvul%2Ba%2BsfIlw0is4%3D" style="width: 50%; margin-bottom: 20px;"></div>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">好了,这些基本上是这个网站的所有文件,<span style="color: black;">此刻</span><span style="color: black;">咱们</span><span style="color: black;">能够</span>运行这个项目了。<span style="color: black;">首要</span>,你想从 GitHub 下载这个项目,链接如下:</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;"><span style="color: black;">https://github.com/crearo/portfolio</span></strong></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">而后</span>你想运行这个项目,<span style="color: black;">这儿</span>是运行 Flask 项目的说明:</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">https://flask.palletsprojects.com/en/2.0.x/quickstart/</span></span></p>
    <h1 style="color: black; text-align: left; margin-bottom: 10px;">最后</h1>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">期盼</span>本文对您有所<span style="color: black;">帮忙</span>!</p>




aikangjian 发表于 2024-9-3 10:40:23

对于这个问题,我有不同的看法...

1fy07h 发表于 2024-11-9 02:03:07

“BS”(鄙视的缩写)‌
页: [1]
查看完整版本: 让咱们用 Flask + Python 构建一个美丽简约的网站(附完整源码)