图片
flask 渲染拼接模版

test.py
from flask import Flask,render_template,make_response
from flask_restful import Api, Resource, reqparse
import  werkzeug
 
app = Flask(__name__)
api = Api(app)
 
class AppointmentController(Resource):
    def __init__(self):
        pass
    def get(self):
        headers = {'Content-Type': 'text/html'}
        return make_response(render_template('index.html'),200,headers)
 
api.add_resource(AppointmentController, '/upload')
 
 
if __name__ == '__main__':
  app.run(debug=True)
base.html
<!DOCTYPE html>
   <html lang="en">
   <head>
     <title>{% block title %}{% endblock title %}</title>
 
 
     <link href="http://netdna.bootstrapcdn.com/bootswatch/2.3.2/united/bootstrap.min.css" rel="stylesheet">
     <link href="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/css/ bootstrap-responsive.min.css" rel="stylesheet">
     <script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
     <script src="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/js/bootstrap.min.js"></script>
</head>
<body>
  <div id="main">
  <h2>index parent!!!</h2>
  <div class="content container">
    {% block main %}{% endblock main %}
  </div>
  </div>
</body>
</html>
index.html
{% extends 'base.html' %}
{% block title %}Page Title{% endblock title %}
{% block main %}
    <h2>This is a child template.</h2>
{% endblock main %}

 

 
 
 
 
 
 
 
 
 
 
 
 
 
 

相关文章:

  • 2022-02-01
  • 2021-07-25
  • 2021-07-14
  • 2021-09-18
  • 2022-12-23
  • 2021-06-19
  • 2021-09-10
  • 2022-01-12
猜你喜欢
  • 2021-06-12
  • 2022-12-23
  • 2021-11-12
  • 2021-09-25
  • 2022-12-23
  • 2021-05-08
  • 2021-11-01
相关资源
相似解决方案