<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="FeedCreator 1.8" -->
<?xml-stylesheet href="https://www.baszerr.eu/lib/exe/css.php?s=feed" type="text/css"?>
<rss version="2.0">
    <channel xmlns:g="http://base.google.com/ns/1.0">
        <title>BaSzErr - blog:2021:01:25</title>
        <description></description>
        <link>https://www.baszerr.eu/</link>
        <lastBuildDate>Wed, 06 May 2026 07:55:08 +0000</lastBuildDate>
        <generator>FeedCreator 1.8</generator>
        <image>
            <url>https://www.baszerr.eu/lib/exe/fetch.php?media=wiki:dokuwiki.svg</url>
            <title>BaSzErr</title>
            <link>https://www.baszerr.eu/</link>
        </image>
        <item>
            <title>2021-01-25_-_non_interactive_docker_container</title>
            <link>https://www.baszerr.eu/doku.php?id=blog:2021:01:25:2021-01-25_-_non_interactive_docker_container</link>
            <description>
&lt;h1 class=&quot;sectionedit1&quot; id=&quot;non_interactive_docker_container&quot;&gt;2021-01-25 - (non)interactive docker container&lt;/h1&gt;
&lt;div class=&quot;level1&quot;&gt;

&lt;p&gt;
you can run docker container to do some non-interactive processing. eg with:
&lt;/p&gt;
&lt;pre class=&quot;code bash&quot;&gt;docker run &lt;span class=&quot;re5&quot;&gt;--rm&lt;/span&gt; myalgo:&lt;span class=&quot;nu0&quot;&gt;4.2&lt;/span&gt; &lt;span class=&quot;re5&quot;&gt;--foo&lt;/span&gt; &lt;span class=&quot;re5&quot;&gt;--bar&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;
when you need to do it interactively, you just add &lt;code&gt;-it&lt;/code&gt;:
&lt;/p&gt;
&lt;pre class=&quot;code bash&quot;&gt;docker run &lt;span class=&quot;re5&quot;&gt;-it&lt;/span&gt; &lt;span class=&quot;re5&quot;&gt;--rm&lt;/span&gt; myalgo:&lt;span class=&quot;nu0&quot;&gt;4.2&lt;/span&gt; &lt;span class=&quot;re5&quot;&gt;--foo&lt;/span&gt; &lt;span class=&quot;re5&quot;&gt;--bar&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;
so far, so good. now how about &lt;a href=&quot;https://en.wikipedia.org/wiki/Continuous integration&quot; class=&quot;interwiki iw_wp&quot; title=&quot;https://en.wikipedia.org/wiki/Continuous integration&quot;&gt;CI&lt;/a&gt; scripts, that on CI server are being run in a non-interactive way, but you also want the very same scripts to be runnable interactively by developers (so that they can eg. &lt;code&gt;^C&lt;/code&gt; it during the run)? it turns out it is fairly simple with &lt;code&gt;tty&lt;/code&gt; command to detect if terminal is interactive or not and &lt;a href=&quot;https://en.wikipedia.org/wiki/bash (Unix shell)&quot; class=&quot;interwiki iw_wp&quot; title=&quot;https://en.wikipedia.org/wiki/bash (Unix shell)&quot;&gt;bash&lt;/a&gt; arrays to pass parameters to &lt;code&gt;docker&lt;/code&gt;:
&lt;/p&gt;
&lt;pre class=&quot;code bash&quot;&gt;&lt;span class=&quot;re2&quot;&gt;EXTRA_FLAGS&lt;/span&gt;=&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;
&lt;span class=&quot;kw1&quot;&gt;if&lt;/span&gt; tty &lt;span class=&quot;re5&quot;&gt;-s&lt;/span&gt;
&lt;span class=&quot;kw1&quot;&gt;then&lt;/span&gt;
  EXTRA_FLAGS+=&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&amp;quot;-it&amp;quot;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;
&lt;span class=&quot;kw1&quot;&gt;fi&lt;/span&gt;
&amp;nbsp;
docker run \
  &lt;span class=&quot;st0&quot;&gt;&amp;quot;&lt;span class=&quot;es3&quot;&gt;${EXTRA_FLAGS[@]}&lt;/span&gt;&amp;quot;&lt;/span&gt; \
  &lt;span class=&quot;re5&quot;&gt;--rm&lt;/span&gt; \
  myalgo:&lt;span class=&quot;nu0&quot;&gt;4.2&lt;/span&gt; &lt;span class=&quot;re5&quot;&gt;--foo&lt;/span&gt; &lt;span class=&quot;re5&quot;&gt;--bar&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;
as a free bonus you can now add multiple optional flags, to the same array and/or use it for all the arguments, to simplify the invocation of &lt;code&gt;docker&lt;/code&gt;.
&lt;/p&gt;

&lt;/div&gt;
</description>
            <author>anonymous@undisclosed.example.com (Anonymous)</author>
            <pubDate>Tue, 15 Jun 2021 20:09:42 +0000</pubDate>
        </item>
        <item>
            <title>2021-01-25_-_the_flask_path</title>
            <link>https://www.baszerr.eu/doku.php?id=blog:2021:01:25:2021-01-25_-_the_flask_path</link>
            <description>
&lt;h1 class=&quot;sectionedit1&quot; id=&quot;the_flask_path&quot;&gt;2021-01-25 - the flask path&lt;/h1&gt;
&lt;div class=&quot;level1&quot;&gt;

&lt;p&gt;
every now and then i use &lt;a href=&quot;https://en.wikipedia.org/wiki/Flask (web framework)&quot; class=&quot;interwiki iw_wp&quot; title=&quot;https://en.wikipedia.org/wiki/Flask (web framework)&quot;&gt;Flask&lt;/a&gt; to get some &lt;a href=&quot;https://en.wikipedia.org/wiki/REST&quot; class=&quot;interwiki iw_wp&quot; title=&quot;https://en.wikipedia.org/wiki/REST&quot;&gt;REST&lt;/a&gt; service up and running in no time. recently i had an interesting case, as &lt;abbr title=&quot;Application Programming Interface&quot;&gt;API&lt;/abbr&gt; i exposed was in a form &lt;code&gt;/api/1/branch/&amp;lt;brn&amp;gt;/stuff&lt;/code&gt;, where &lt;code&gt;brn&lt;/code&gt; was a &lt;a href=&quot;https://en.wikipedia.org/wiki/Version control system&quot; class=&quot;interwiki iw_wp&quot; title=&quot;https://en.wikipedia.org/wiki/Version control system&quot;&gt;VCS&lt;/a&gt; branch name, that the &lt;abbr title=&quot;Application Programming Interface&quot;&gt;API&lt;/abbr&gt; referred to. after some time, one of the project teams started to send out their branches data. branches however were in the form &lt;code&gt;feature/foo-bar&lt;/code&gt;… and boom – &lt;abbr title=&quot;Application Programming Interface&quot;&gt;API&lt;/abbr&gt; returned an error, that path does not exist. so the obvious solution was to &lt;abbr title=&quot;Uniform Resource Locator&quot;&gt;URL&lt;/abbr&gt;-encode it, i.e. &lt;code&gt;feature%2Ffoo-bar&lt;/code&gt;… and the same! it turned out that Flask is kind enough to parse &lt;abbr title=&quot;Uniform Resource Locator&quot;&gt;URL&lt;/abbr&gt;-encoded data for you. convenient. unless it is not sth that you want… :/
&lt;/p&gt;

&lt;p&gt;
the answer is “parameter types”. when you normally type in route in flask, it looks like this:
&lt;/p&gt;
&lt;pre class=&quot;code python&quot;&gt;&lt;span class=&quot;sy0&quot;&gt;@&lt;/span&gt;app.&lt;span class=&quot;me1&quot;&gt;route&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&amp;quot;/api/1/branch/&amp;lt;brn&amp;gt;/stuff&amp;quot;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;
&lt;span class=&quot;kw1&quot;&gt;def&lt;/span&gt; handle_stuff&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;brn&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;:
    foobar&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;brn&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;
you are implicitly getting &lt;code&gt;string&lt;/code&gt; parameter type. this is where (and why) Flask &lt;abbr title=&quot;Uniform Resource Locator&quot;&gt;URL&lt;/abbr&gt;-decides &lt;code&gt;%2F&lt;/code&gt; into &lt;code&gt;/&lt;/code&gt;.
&lt;/p&gt;

&lt;p&gt;
there are however other types, like &lt;code&gt;int&lt;/code&gt; and &lt;code&gt;path&lt;/code&gt;. in particular &lt;code&gt;path&lt;/code&gt; can handle &lt;code&gt;%2F&lt;/code&gt; properly. so the “correct” code is:
&lt;/p&gt;
&lt;pre class=&quot;code python&quot;&gt;&lt;span class=&quot;sy0&quot;&gt;@&lt;/span&gt;app.&lt;span class=&quot;me1&quot;&gt;route&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&amp;quot;/api/1/branch/&amp;lt;path:brn&amp;gt;/stuff&amp;quot;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;
&lt;span class=&quot;kw1&quot;&gt;def&lt;/span&gt; handle_stuff&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;brn&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;:
    foobar&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;brn&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;
now users can send out &lt;code&gt;feature%2Ffoo-bar&lt;/code&gt; and a proper function will get called, with &lt;code&gt;brn&lt;/code&gt; set to &lt;code&gt;feature/foo-bar&lt;/code&gt;, as expected.
&lt;/p&gt;

&lt;p&gt;
it took me a bit of searching. the main problem was that i was looking for ways to “disable &lt;abbr title=&quot;Uniform Resource Locator&quot;&gt;URL&lt;/abbr&gt;-encoding in flask” (and similar) and there i got bunch of “can&amp;#039;t do”, “won&amp;#039;t work” and rally nasty hacks in the implementation of a backend. in the end, the solution turned out to be trivial… once you know what are you looking for. it would be nice if it was more explicit in a documentation (&lt;abbr title=&quot;Frequently Asked Questions&quot;&gt;FAQ&lt;/abbr&gt; maybe?).
&lt;/p&gt;

&lt;/div&gt;
</description>
            <author>anonymous@undisclosed.example.com (Anonymous)</author>
            <pubDate>Tue, 15 Jun 2021 20:09:42 +0000</pubDate>
        </item>
    </channel>
</rss>
