Browse Source

Web

pull/165/head
Jure Šorn 1 year ago
parent
commit
f31a8382d6
2 changed files with 2 additions and 0 deletions
  1. 1
      README.md
  2. 1
      index.html

1
README.md

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

1
index.html

@ -2096,6 +2096,7 @@ app.run(host=<span class="hljs-keyword">None</span>, port=<span class="hljs-keyw
</code></pre></div> </code></pre></div>
<ul> <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>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>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><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> <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