Browse Source

Web, Virtual environments

main
Jure Šorn 16 hours ago
parent
commit
8447a11ca0
3 changed files with 7 additions and 7 deletions
  1. 4
      README.md
  2. 8
      index.html
  3. 2
      pdf/remove_links.py

4
README.md

@ -2563,7 +2563,7 @@ app.run(host=None, port=None, debug=None) # Or: $ flask --app FILE run [--ARG[=
```python
@app.route('/img/<path:filename>')
def serve_file(filename):
return fl.send_from_directory('DIRNAME/', filename)
return fl.send_from_directory('DIRNAME', filename)
```
### Dynamic Request
@ -3549,7 +3549,7 @@ cdef class <class_name>:
```perl
$ python3 -m venv NAME # Creates virtual environment in current directory.
$ source NAME/bin/activate # Activates env. On Windows run `NAME\Scripts\activate`.
$ source NAME/bin/activate # Activates it. On Windows run `NAME\Scripts\activate`.
$ pip3 install LIBRARY # Installs the library into active environment.
$ python3 FILE # Runs the script in active environment. Also `./FILE`.
$ deactivate # Deactivates the active virtual environment.

8
index.html

@ -56,7 +56,7 @@
<body>
<header>
<aside>February 27, 2025</aside>
<aside>February 28, 2025</aside>
<a href="https://gto76.github.io" rel="author">Jure Šorn</a>
</header>
@ -2107,7 +2107,7 @@ app.run(host=<span class="hljs-keyword">None</span>, port=<span class="hljs-keyw
</ul>
<div><h3 id="staticrequest">Static Request</h3><pre><code class="python language-python hljs"><span class="hljs-meta">@app.route('/img/&lt;path:filename&gt;')</span>
<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">serve_file</span><span class="hljs-params">(filename)</span>:</span>
<span class="hljs-keyword">return</span> fl.send_from_directory(<span class="hljs-string">'DIRNAME/'</span>, filename)
<span class="hljs-keyword">return</span> fl.send_from_directory(<span class="hljs-string">'DIRNAME'</span>, filename)
</code></pre></div>
<div><h3 id="dynamicrequest">Dynamic Request</h3><pre><code class="python language-python hljs"><span class="hljs-meta">@app.route('/&lt;sport&gt;')</span>
@ -2898,7 +2898,7 @@ px.line(df, x=<span class="hljs-string">'Date'</span>, y=<span class="hljs-strin
self.&lt;attr_name&gt; = &lt;arg_name&gt;
</code></pre>
<div><h3 id="virtualenvironments">Virtual Environments</h3><p><strong>System for installing libraries directly into project's directory.</strong></p><pre><code class="python hljs">$ python3 -m venv NAME <span class="hljs-comment"># Creates virtual environment in current directory.</span>
$ source NAME/bin/activate <span class="hljs-comment"># Activates env. On Windows run `NAME\Scripts\activate`.</span>
$ source NAME/bin/activate <span class="hljs-comment"># Activates it. On Windows run `NAME\Scripts\activate`.</span>
$ pip3 install LIBRARY <span class="hljs-comment"># Installs the library into active environment.</span>
$ python3 FILE <span class="hljs-comment"># Runs the script in active environment. Also `./FILE`.</span>
$ deactivate <span class="hljs-comment"># Deactivates the active virtual environment.</span>
@ -2942,7 +2942,7 @@ $ deactivate <span class="hljs-comment"># Deactivates the active
<footer>
<aside>February 27, 2025</aside>
<aside>February 28, 2025</aside>
<a href="https://gto76.github.io" rel="author">Jure Šorn</a>
</footer>

2
pdf/remove_links.py

@ -8,7 +8,7 @@ from pathlib import Path
MATCHES = {
'<strong>For details about sort(), sorted(), min() and max() see <a href="#sortable">Sortable</a>.</strong>': '<strong>For details about sort(), sorted(), min() and max() see Sortable (p. 16).</strong>',
'<strong>Module <a href="#operator">operator</a> has function itemgetter() that can replace listed <a href="#lambda">lambdas</a>.</strong>': '<strong>Module \'operator\' (p. 31) has function itemgetter() that can replace listed lambdas (p. 11).</strong>',
'<strong>Module <a href="#operator">operator</a> has function itemgetter() that can replace listed <a href="#lambda">lambdas</a>.</strong>': '<strong>Module \'operator\' has function itemgetter() that can replace listed lambdas (p. 31).</strong>',
'<strong>This text uses the term collection instead of iterable. For rationale see <a href="#collection">Collection</a>.</strong>': '<strong>This text uses the term collection instead of iterable. For rationale see Collection (p. 18).</strong>',
'<strong>Adding <code class="python hljs"><span class="hljs-string">\'!r\'</span></code> to the expression converts object to string by calling its <a href="#class">repr()</a> method.</strong>': '<strong>Adding <code class="python hljs"><span class="hljs-string">\'!r\'</span></code> to the expression converts object to string by calling its repr() method.</strong>',
'<strong>It can be any <a href="#callable">callable</a>, but is usually implemented as a function that returns a <a href="#closure">closure</a>.</strong>': '<strong>It can be any callable, but is usually implemented as a function that returns a closure.</strong>',

Loading…
Cancel
Save