Project 3:Personal website
基于python中flask包(library)的personal website开发;
本地网页制作
准备工作
pip install flask
在本地(localhost)编辑网页的方法
from flask import Flask
app = Flask(__name__)
@app.route('/home/')
def home():
return "Website content goes here!"
if __name__=="__main__":
app.run(port=5001,debug=False)
debug=True则可以随时更改;
if __name__=="__main__"
代表运行此程序时——即调试状态;
HTML的初始代码
homepage
#HTML加入网站
<!DOCTYPE html>
<html>
<body>
<h1>My homepage</h1>
<p>This is a test website</p>
</body>
</html>
创建layoutHTML文件,酱homepage和aboutpage作为子网站加入
layeout.HTML
#上述代码将被放到下列layout代码的blockcontent位置上
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<header>
<div class="container">
<h1 class="logo">Qi's web app</h1>
<strong><nav>
<ul class="menu">
<li><a href="{
{ url_for('home') }}">Home</a></li>
<li><a href="{
{ url_for('about') }}">About</a></li>
</ul