<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title>Fastapi - Category - JMS Blog</title><link>/categories/fastapi/</link><description>Fastapi - Category - JMS Blog</description><generator>Hugo -- gohugo.io</generator><language>en</language><lastBuildDate>Wed, 12 Aug 2020 00:00:00 +0000</lastBuildDate><atom:link href="/categories/fastapi/" rel="self" type="application/rss+xml"/><item><title>Timezone lookup using latitude and longitud (part 2)</title><link>/posts/2020-08-12-timezone-finder-2/</link><pubDate>Wed, 12 Aug 2020 00:00:00 +0000</pubDate><author>jms</author><guid>/posts/2020-08-12-timezone-finder-2/</guid><description><![CDATA[<p>For the fastapi project we are going to use Sqlalchemy and postgresql
taking some reference from the fastapi documentation.</p>
<div class="code-block code-line-numbers open" style="counter-reset: code-block 0">
    <div class="code-header language-bash">
        <span class="code-title"><i class="arrow fas fa-angle-right" aria-hidden="true"></i></span>
        <span class="ellipses"><i class="fas fa-ellipsis-h" aria-hidden="true"></i></span>
        <span class="copy" title="Copy to clipboard"><i class="far fa-copy" aria-hidden="true"></i></span>
    </div><div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl"><span class="c1"># create a virtualenv, with any tool: poetry, pipenv, virtualenv module, etc </span>
</span></span><span class="line"><span class="cl">pip install fastapi uvicorn aiofiles SQLAlchemy psycopg2-binary</span></span></code></pre></div></div>
<p>project structure</p>
<div class="code-block code-line-numbers" style="counter-reset: code-block 0">
    <div class="code-header language-bash">
        <span class="code-title"><i class="arrow fas fa-angle-right" aria-hidden="true"></i></span>
        <span class="ellipses"><i class="fas fa-ellipsis-h" aria-hidden="true"></i></span>
        <span class="copy" title="Copy to clipboard"><i class="far fa-copy" aria-hidden="true"></i></span>
    </div><div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">.
</span></span><span class="line"><span class="cl">├── Dockerfile
</span></span><span class="line"><span class="cl">├── LICENSE
</span></span><span class="line"><span class="cl">├── main.py
</span></span><span class="line"><span class="cl">├── README.md
</span></span><span class="line"><span class="cl">├── requirements.txt
</span></span><span class="line"><span class="cl">└── timezone_utils
</span></span><span class="line"><span class="cl">    ├── database.py
</span></span><span class="line"><span class="cl">    ├── __init__.py
</span></span><span class="line"><span class="cl">    ├── models.py
</span></span><span class="line"><span class="cl">    ├── schemas.py
</span></span><span class="line"><span class="cl">    └── utils.py
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="m">1</span> directory, <span class="m">10</span> files</span></span></code></pre></div></div>
<p>we define the models, schemas and engine for sqlalchemy and the api in the package <code>timezone_utils</code></p>]]></description></item><item><title>Timezone lookup using latitude and longitude (part 1)</title><link>/posts/2020-08-11-timezone-finder-1/</link><pubDate>Tue, 11 Aug 2020 00:00:00 +0000</pubDate><author>jms</author><guid>/posts/2020-08-11-timezone-finder-1/</guid><description><![CDATA[<p>First timezones are evil, but sometimes you need to work with them. Sometimes is easy to consume some third party api to get timezone information based on a given location using geocoding but there also exists some alternatives.</p>
<p>Then inspired on this <a href="https://github.com/evansiroky/timezone-boundary-builder" target="_blank" rel="noopener noreffer ">blog post</a> and the project <a href="https://github.com/evansiroky/timezone-boundary-builder" target="_blank" rel="noopener noreffer ">Timezone boundary builder</a> decided to create a test project using fastapi and postgis to do the timezone lookup using the latitude and longitude.</p>]]></description></item></channel></rss>