Browse Source

Flask

pull/167/head
Jure Šorn 1 year ago
parent
commit
6482fdb1ce
2 changed files with 2 additions and 2 deletions
  1. 2
      README.md
  2. 2
      index.html

2
README.md

@ -2550,7 +2550,7 @@ def serve_file(filename):
def serve_html(sport):
return flask.render_template_string('<h1>{{title}}</h1>', title=sport)
```
* **Use `'render_template(filename, <kwargs>)'` to render template file.**
* **Use `'render_template(filename, <kwargs>)'` to render file located in templates dir.**
* **To return an error code use `'abort(<int>)'` and to redirect use `'redirect(<url>)'`.**
* **`'request.args[<str>]'` returns parameter from the query string (URL part after '?').**
* **Use `'session[key] = value'` to store session data like username, etc.**

2
index.html

@ -2094,7 +2094,7 @@ app.run(host=<span class="hljs-keyword">None</span>, port=<span class="hljs-keyw
</code></pre></div>
<ul>
<li><strong>Use <code class="python hljs"><span class="hljs-string">'render_template(filename, &lt;kwargs&gt;)'</span></code> to render template file.</strong></li>
<li><strong>Use <code class="python hljs"><span class="hljs-string">'render_template(filename, &lt;kwargs&gt;)'</span></code> to render file located in templates dir.</strong></li>
<li><strong>To return an error code use <code class="python hljs"><span class="hljs-string">'abort(&lt;int&gt;)'</span></code> and to redirect use <code class="python hljs"><span class="hljs-string">'redirect(&lt;url&gt;)'</span></code>.</strong></li>
<li><strong><code class="python hljs"><span class="hljs-string">'request.args[&lt;str&gt;]'</span></code> returns parameter from the query string (URL part after '?').</strong></li>
<li><strong>Use <code class="python hljs"><span class="hljs-string">'session[key] = value'</span></code> to store session data like username, etc.</strong></li>

Loading…
Cancel
Save