0

I am new to flask,and I try to use Flask-RESTful to make flask work in restful way. However, I cannot render the HTML, while I try to return render_template it returns the source code of the HTML, it is in this way Flask render template not working

I try the answer and it works,however I cannot input parameters like

render_template('index.html',titile="title","passwd"="123456")

It shows me SyntaxError: keyword can't be an expression. Can any one help me solve this problem?

Community
  • 1
  • 1
poople
  • 165
  • 2
  • 7

2 Answers2

3

You have quotation marks wrapped around your passwd, which is invalid syntax when using kwargs.

Just remove the "

render_template('index.html', titile="title", passwd="123456")
Wondercricket
  • 7,651
  • 2
  • 39
  • 58
  • haha, its my fault, I make a small mistake. You and Brian KH give me the right answer, thanks! – poople Aug 29 '15 at 04:58
  • @poople I am glad I was able to help! If the answer has provided you a solution to your problem, feel free to accept the answer – Wondercricket Aug 29 '15 at 17:45
3

Flask-RESTful does not use render_template. It is designed to work with REST API calls and render JSON responses. Unless you are building a REST API, you don't need Flask-RESTful, just Flask.

To address your specific render_template() issue, I agree with Wondercricket.

Kelly Keller-Heikkila
  • 2,544
  • 6
  • 23
  • 35
  • I think you are right. At the beginning, I just use Flask-RESTful to make flask work in RESTFUL way, however, I cannot find the render method, but I try this way http://stackoverflow.com/questions/19315567/flask-render-template-not-working. It works, thanks! – poople Aug 29 '15 at 05:01