Skip to content

Commit 1de80c5

Browse files
committed
Web
1 parent 7a469a3 commit 1de80c5

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2538,8 +2538,8 @@ import flask
25382538
```
25392539

25402540
```python
2541-
app = flask.Flask(__name__)
2542-
app.run(host=None, port=None, debug=None)
2541+
app = flask.Flask(__name__) # Put above function definitions.
2542+
app.run(host=None, port=None, debug=None) # Run after function definitions.
25432543
```
25442544
* **Starts the app at `'http://localhost:5000'`. Use `'host="0.0.0.0"'` to run externally.**
25452545
* **Install a WSGI server like [Waitress](https://flask.palletsprojects.com/en/latest/deploying/waitress/) and a HTTP server such as [Nginx](https://flask.palletsprojects.com/en/latest/deploying/nginx/) for better security.**
@@ -2561,7 +2561,7 @@ def serve_html(sport):
25612561
* **Use `'render_template(filename, <kwargs>)'` to render file located in templates dir.**
25622562
* **To return an error code use `'abort(<int>)'` and to redirect use `'redirect(<url>)'`.**
25632563
* **`'request.args[<str>]'` returns parameter from the query string (URL part after '?').**
2564-
* **Use `'session[key] = value'` to store session data like username, etc.**
2564+
* **`'session[<str>] = <obj>'` stores session data. Needs `'app.secret_key = <str>'`.**
25652565

25662566
### REST Request
25672567
```python

index.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2088,8 +2088,8 @@ <h3 id="format-2">Format</h3><div><h4 id="forstandardtypesizesandmanualalignment
20882088
</code></pre></div>
20892089

20902090

2091-
<pre><code class="python language-python hljs">app = flask.Flask(__name__)
2092-
app.run(host=<span class="hljs-keyword">None</span>, port=<span class="hljs-keyword">None</span>, debug=<span class="hljs-keyword">None</span>)
2091+
<pre><code class="python language-python hljs">app = flask.Flask(__name__) <span class="hljs-comment"># Put above function definitions.</span>
2092+
app.run(host=<span class="hljs-keyword">None</span>, port=<span class="hljs-keyword">None</span>, debug=<span class="hljs-keyword">None</span>) <span class="hljs-comment"># Run after function definitions.</span>
20932093
</code></pre>
20942094
<ul>
20952095
<li><strong>Starts the app at <code class="python hljs"><span class="hljs-string">'http://localhost:5000'</span></code>. Use <code class="python hljs"><span class="hljs-string">'host="0.0.0.0"'</span></code> to run externally.</strong></li>
@@ -2110,7 +2110,7 @@ <h3 id="format-2">Format</h3><div><h4 id="forstandardtypesizesandmanualalignment
21102110
<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>
21112111
<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>
21122112
<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>
2113-
<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>
2113+
<li><strong><code class="python hljs"><span class="hljs-string">'session[&lt;str&gt;] = &lt;obj&gt;'</span></code> stores session data. Needs <code class="python hljs"><span class="hljs-string">'app.secret_key = &lt;str&gt;'</span></code>.</strong></li>
21142114
</ul>
21152115
<div><h3 id="restrequest">REST Request</h3><pre><code class="python language-python hljs"><span class="hljs-meta">@app.post('/&lt;sport&gt;/odds')</span>
21162116
<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">serve_json</span><span class="hljs-params">(sport)</span>:</span>

0 commit comments

Comments
 (0)