炫意html5
最早CSS3和HTML5移动技术网站之一

flask的app.py

有没有大佬能做出图中的效果,源码在下面,不会组合

服务器程序app.py

app.py

from flask import Flask, render_template, request

app = Flask(name)

@app.route(‘/’)
def index():
uname = request.values.get(‘uname’) if ‘uname’ in request.values else ”
return render_template(‘index.html’, uname=uname)

if name == ‘main‘:
app.run(debug=True)

<!– templates\index.html –>
<!DOCTYPE html>
<html>
<head>
<title>flask模板</title>
</head>
<body>

    <h3>{{ uname }} 您好,这是首页</h3>
<a href="https://q.cnblogs.com/login">登录</a>
</body>

</html>

客户端程序client.py

client.py

import urllib.request as rq
import urllib.parse as pa

url = ‘http://127.0.0.1:5000’

def getindex():
try:
uname = pa.quote(‘张三’)
data = ‘uname=%s’ % uname
html = rq.urlopen(url + ‘?’ + data).read().decode(‘utf-8’)
print(html)
except Exception as e:
print(e)

if name == ‘main‘:
getindex()
print(‘END’)

回答

搞不懂,都在哪找的奇奇怪怪的教程

# demo/app.py
from flask import Flask, render_template, request

app = Flask(__name__,
            static_folder='static',
            template_folder='templates')


@app.route('/')
def index():
    uname = request.values.get('uname') if 'uname' in request.values else ''
    return render_template('index.html', uname=uname)


if __name__ == '__main__':
    app.run(debug=True)

<br>

<!-- demo/templates/index.html -->
<!DOCTYPE html>
<html>
<head>
<title>flask模板</title>
</head>
<body>

    <h3>{{ uname }} 您好,这是首页</h3>

    <a href="https://q.cnblogs.com/login">登录</a>
</body>
</html>

炫意HTML5 » flask的app.py

Java基础教程Android基础教程