<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Acacio Leclercqz on Medium]]></title>
        <description><![CDATA[Stories by Acacio Leclercqz on Medium]]></description>
        <link>https://medium.com/@leclercqz.acacio?source=rss-e9d3b4eae8e2------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*hcPMyd4hL5fhQxdX5XOJBQ.jpeg</url>
            <title>Stories by Acacio Leclercqz on Medium</title>
            <link>https://medium.com/@leclercqz.acacio?source=rss-e9d3b4eae8e2------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 18 Nov 2026 07:29:31 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@leclercqz.acacio/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[The Python Coronavirus Tracker]]></title>
            <link>https://medium.com/@leclercqz.acacio/the-python-coronavirus-tracker-3a757a01e8e?source=rss-e9d3b4eae8e2------2</link>
            <guid isPermaLink="false">https://medium.com/p/3a757a01e8e</guid>
            <category><![CDATA[selenium]]></category>
            <category><![CDATA[tracking]]></category>
            <category><![CDATA[coronavirus]]></category>
            <category><![CDATA[python-scripting]]></category>
            <category><![CDATA[web-scraping]]></category>
            <dc:creator><![CDATA[Acacio Leclercqz]]></dc:creator>
            <pubDate>Tue, 03 Mar 2020 16:30:45 GMT</pubDate>
            <atom:updated>2020-03-03T16:31:59.318Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*V0NNbyFfSNKBQaQYiQj-NA.jpeg" /></figure><p>I just wrote a Python script based on the library Selenium to retrieve all the data from the <a href="https://bnonews.com/index.php/2020/02/the-latest-coronavirus-cases/">BNO news Tracking coronavirus : Map, data and timeline</a>. it allows you to keep historical data and see the evolution of the corona virus in countries around the world.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LqmtothzXRPp8zoVSlCOlw.png" /></figure><h4>WHY ?</h4><p>BNO news are just updating their datas, that’s why I wanted to keep an eye on the evolution of those numbers.</p><h4>HOW to track the data ?</h4><p>If you are familiar with git and python, Isuggest you to visit my Github repository and you will be able to git clone the project : <a href="https://github.com/ak6o/corona_tracker">https://github.com/ak6o/corona_tracker</a>.</p><p>if you want your file to be up to date, I advise you to run the script at least once a day.</p><p>if you have any suggestion or have trouble to install don’t hesitate to leave a comment.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3a757a01e8e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Quickly deploying a Django app with uWSGI and NGINX]]></title>
            <link>https://medium.com/@leclercqz.acacio/quickly-deploying-a-django-app-with-uwsgi-and-nginx-5fee98c1c745?source=rss-e9d3b4eae8e2------2</link>
            <guid isPermaLink="false">https://medium.com/p/5fee98c1c745</guid>
            <category><![CDATA[django]]></category>
            <category><![CDATA[nginx]]></category>
            <category><![CDATA[servers]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[uwsgi]]></category>
            <dc:creator><![CDATA[Acacio Leclercqz]]></dc:creator>
            <pubDate>Thu, 09 Jan 2020 16:48:59 GMT</pubDate>
            <atom:updated>2020-02-19T09:50:33.745Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/820/1*8Sb1KJLrfQPEakuauf4JKA.png" /></figure><p>If you want to learn how to deploy a django app on a Linux server on Debian10 you are at the right place. We proceed the deployement on a ovh VPS but if you have an another provider it should be the same.</p><h3>Prerequisites</h3><p>We will assume that the initial server setup is already done and you have Python 3.x installed.</p><h3>Setting up the environment</h3><h3>Clone your project</h3><p>let’s install git and clone the project at ~/pathto/your_project/:</p><pre>$ sudo apt install git<br>$ git clone <a href="https://your_project.git/">https://your_project.git</a> ~/pathto/your_project/</pre><h3>Create a Python virtual environment</h3><p>We will work within a Python virtual environment. Let’s install venv and create a new virtual environment:</p><pre>$ sudo apt install python3-venv<br>$ python3 -m venv ~/pathto/project_env<br>$ source ~/pathto/project_env/bin/activate</pre><p>Your prompt should now look like this:</p><pre>(project_env) user@host:</pre><h3>Install and setup Django</h3><p>Now that the virtual environment is activated, let’s install Django and other dependencies using pip (you can run the commands below, assuming that you have written a requirements.txt):</p><pre>(project_env) $ cd ~/pathto/your_project/<br>(project_env) $ pip install -r requirements.txt</pre><p>You can try to run the app to check if everything is OK (you may need to download other prerequisites such as the database back-end).</p><h3>Install and setup uWSGI</h3><p>Let’s install uWSGI inside the virtual environment:</p><pre>(project_env) $ pip install uwsgi</pre><p>and try it out by running the Django app:</p><pre>(project_env) $ cd ~/pathto/your_project/<br>(project_env) $ uwsgi --http-socket :8000 --module your_project.wsgi</pre><p>Your app should now be running on the port 8000 of your server’s IP address.</p><p>We will create a your_project.ini configuration file for easier management (with the minimal configuration above):</p><pre>[uwsgi]<br>http-socket = :8000<br>chdir = /fullpathto/your_project/ # path to the Django project<br>module = your_project.wsgi<br>home = /fullpathto/project_env # path to the virtual environment</pre><p>and test it by deactivating the virtual environment and run uWSGI by using the binary file of the virtual environment:</p><pre>(project_env) $ deactivate<br>$ ~/pathto/project_env/bin/uwsgi --ini ~/pathto/your_project.ini</pre><p>Your app should be running, and you will find further configuration options on the <a href="https://uwsgi-docs.readthedocs.io/en/latest/">uWSGI documentation page</a>.</p><h3>Deploying the app</h3><h3>Configure Firewall Rules</h3><p>We will set up some basic firewall rules to allow connections from SSH and NGINX (make sure you have SSH allowed otherwise you will lose your connection and <em>not</em> get it back).</p><pre>$ sudo apt install ufw<br>$ sudo ufw allow ssh<br>$ sudo ufw allow &#39;Nginx Full&#39;<br>$ sudo ufw enable</pre><h3>Install and configure NGINX</h3><p>We will first install NGINX and remove the default site configuration:</p><pre>$ sudo apt install nginx<br>$ rm /etc/nginx/sites-enabled/default</pre><p>We will now create a file called your_project.conf in the /etc/nginx/sites-available/ directory, and write the following lines in it (if you wish to use your domain name instead of the server’s IP address, you should update the file accordingly):</p><pre>upstream django {<br>    server 127.0.0.1:8000;<br>}server {<br>    server_name default;location / {<br>        proxy_pass <a href="http://localhost:8000/">http://localhost:8000;</a><br>    }<br>}</pre><p>and create a symbolic link to this file from /etc/nginx/sites-enabled/:</p><pre>$ sudo ln -s /etc/nginx/sites-available/your_project.conf /etc/nginx/sites-enabled/</pre><p>and finally restart NGINX:</p><pre>$ sudo systemctl restart nginx</pre><h3>Create a new service with systemd</h3><p>Create a systemd unit called your_project to allow your application to behave as a service. Create a new file at /lib/systemd/system/your_project.service and add the following content:</p><pre>[Unit]<br>Description=your_project<br># After=postgresql.service # specify your database if needed[Service]<br>Type=simple<br>Restart=always<br>RestartSec=5s<br>ExecStart=/pathto/venv/bin/uwsgi --ini /pathto/your_project.ini[Install]<br>WantedBy=multi-user.target</pre><h3>Test the server</h3><p>Let’s start your project server:</p><pre>$ sudo systemctl start your_app.service</pre><p>Your app should now be running, and available at the server’s IP address!</p><p>Thanks to Shoei for working with me on development and deployment of the project.</p><p><a href="https://www.linkedin.com/in/acacio-leclercqz/">Acacio Leclercqz</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5fee98c1c745" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Build a dashboard from scratch using Dash Python framework]]></title>
            <link>https://medium.com/@leclercqz.acacio/build-a-dashboard-from-scratch-using-dash-python-framework-7bd0ea986f6?source=rss-e9d3b4eae8e2------2</link>
            <guid isPermaLink="false">https://medium.com/p/7bd0ea986f6</guid>
            <category><![CDATA[dash]]></category>
            <category><![CDATA[bootstrap]]></category>
            <category><![CDATA[plotly]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[dashboard]]></category>
            <dc:creator><![CDATA[Acacio Leclercqz]]></dc:creator>
            <pubDate>Thu, 27 Jun 2019 12:14:20 GMT</pubDate>
            <atom:updated>2019-11-13T10:16:35.902Z</atom:updated>
            <content:encoded><![CDATA[<h3>Building a dashboard from scratch using Dash Python framework</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KcdEFDmdt5qj0yVslGcD2w.png" /></figure><p>Dash is a Python framework for building web applications. We will use this framework to build a little Dashboard from scratch. Dash will allow us to build a beautiful dashboard without writing any line of hmtl, css or javascript.</p><p>Let’s start and import some packages.</p><pre>import dash<br>import dash_core_components as dcc<br>import dash_html_components as html<br>import dash_bootstrap_components as dbc<br>from dash.dependencies import Input, Output, State</pre><pre>import plotly<br>import plotly.plotly as py<br>import plotly.graph_objs as go</pre><pre>external_stylesheets =[&#39;<a href="https://codepen.io/chriddyp/pen/bWLwgP.css&#39;">https://codepen.io/chriddyp/pen/bWLwgP.css&#39;</a>, dbc.themes.BOOTSTRAP]<br>app = dash.Dash(__name__, external_stylesheets=external_stylesheets)</pre><p>dash_core_components , dash _html_components and dash_bootstrap_components will enable to generate HTML and CSS contents using Python. Plotly packages will be very useful when we want to display nice graphs which are the dashboard core components . External style sheets are just CSS sheets that will make our dashboard elegant.</p><h3><strong>1) Navigation bar and button</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/919/1*xJnFHz-h72l5oY2AHAcDJg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/559/1*zEMeb8rycI0mmRRNeUjkBA.png" /></figure><p>The first element that we will implement in our web application is the navigation bar including the button that will display a modal.</p><pre>navbar = dbc.NavbarSimple(<br>       children=<br>    [<br>        dbc.Button(&quot;BLOG&quot;, id=&quot;openBlog&quot;, size=&quot;lg&quot;),<br>        dbc.Modal(<br>        [<br>          dbc.ModalHeader(&quot;BLOG&quot;),<br>          dbc.ModalBody(&quot;It&#39;s the body&quot;)<br>          dbc.ModalFooter(<br>          dbc.Button(&quot;Close&quot;,id=&quot;closeBlog&quot;,className=&quot;ml-auto&quot;),),</pre><pre>        ], id=&quot;modalBlog&quot;,<br>        ),<br>    ],<br>    color=&quot;grey&quot;,<br>    dark=True,<br>)</pre><p>We start by define a variable that will contain all the navigation bar elements. To create it we use the dash bootstrap components “NavbarSimple”, you can find all the bootstrap components <a href="https://dash-bootstrap-components.opensource.faculty.ai/l/components/navbar">on this page</a>. This navigation bar contains a single button with the id “openBlog”. <strong>Ids are very important</strong> because it allows you to identify which button you clicked in the callback and associate it to an action. Here the action is to display the modal.</p><p>Now that we have the navigation bar in our “navbar” variable we will pass it to our app layout and then run the server locally in order to see what we have built.</p><pre>app.layout = html.Div([navbar], style={&#39;backgroundColor&#39;:&#39;black&#39;})</pre><pre>if __name__ == &#39;__main__&#39;:<br>    app.run_server(debug=True)</pre><p>Now just run your python code and you should be able to see the result running on <a href="http://127.0.0.1:8050/">http://127.0.0.1:8050/</a>.</p><p>You can notice that you can click on the button but you can’t see the modal show up, it’s because we didn’t set any callback. Then come back to your code and let’s just add it with the function associate to it.</p><pre>def toggle_modal(input1, input2, is_open):<br>    if n1 or n2 :<br>        return not is_open<br>    return is_open</pre><pre>app.callback(<br>     Output(&quot;modalBlog&quot;, &quot;is_open&quot;),<br>    [Input(&quot;openBlog&quot;, &quot;n_clicks&quot;),Input(&quot;closeBlog&quot;, &quot;n_clicks&quot;)],<br>    [State(&quot;modalBlog&quot;, &quot;is_open&quot;)],<br>)(toggle_modal)</pre><p>The Output is what our function toggle_modal returns, Inputs and State are the arguments of our function. As we have 2 input and 1 state we have 3 arguments to our function.</p><h3>2) Content arrangement and card</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/595/1*-GSqNDyZkY5W-cpcIgBkyw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/322/1*1QYXB-r9SRTnGzLi8bjatA.png" /></figure><p>Bootstrap grid system allows us to organize page’s content in rows and columns. It allows up to 12 columns across the page, we don’t have to use all the twelve column individually, we can group them to use wider columns. Bootstrap grid system is responsive which means that contents will be re-arranged depending on the screen size. On small screen each column will be stacked on top of each other.</p><p>Create the card, as we need 4 cards we will just create one function that takes the title and the content of the card in parameters</p><pre>def create_card(title, content):<br>    card = dbc.Card(<br>        dbc.CardBody(<br>            [<br>                html.H4(title, className=&quot;card-title&quot;),<br>                html.Br(),<br>                html.Br(),<br>                html.H2(content, className=&quot;card-subtitle&quot;),<br>                html.Br(),<br>                html.Br(),<br>                ]<br>        ),<br>        color=&quot;info&quot;, inverse=True<br>    )<br>    return(card)</pre><pre>card4 = create_card(&quot;Number of Comment on Articles&quot;, &quot;None Comments&quot;)<br>card3 = create_card(&quot;Number of Articles&quot;, &quot;None Articles&quot;)<br>card2 = create_card(&quot;Number of Likes On Articles&quot;, &quot;None Likes&quot;)<br>card1 = create_card(&quot;Number of Helpfuls On Articles&quot;, &quot;None    Helpfuls&quot;)</pre><p>Now that our cards are created we just have to put them in the row and choose the size for the columns. dbc.Row and dbc.Col are dash bootstrap components to define a row that contains 4 cards columns. The parameter “md” passed on columns components is to set the size for your columns trough media queries.</p><pre>graphRow0 = dbc.Row([dbc.Col(id=&#39;card1&#39;, children=[card1], md=3), dbc.Col(id=&#39;card2&#39;, children=[card2], md=3), dbc.Col(id=&#39;card3&#39;, children=[card3], md=3), dbc.Col(id=&#39;card4&#39;, children=[card4],        md=3)])</pre><p>You can pass more than one parameter in order to organize your app differently for different size of screen.</p><pre>sm = /* Small devices (tablets, 768px and up) */<br>@media (min-width: @screen-sm-min) { ... }<br><br>md = /* Medium devices (desktops, 992px and up) */<br>@media (min-width: @screen-md-min) { ... }<br><br>lg = /* Large devices (large desktops, 1200px and up) */<br>@media (min-width: @screen-lg-min) { ... }</pre><p>Finally pass everything to our app layout.</p><pre>app.layout = html.Div([navbar,html.Br(),graphRow0], style={&#39;backgroundColor&#39;:&#39;black&#39;})</pre><h3>3) Plot nice graphs with Plotly</h3><p>If you want to use Plotly to display your graphs, you will need to create an account on Plotly and connect to their API. You can find all the documentations on how to connect their API and start using Plotly <a href="https://plot.ly/python/getting-started/">here</a>.</p><h4>Pie graph and bar graph</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/795/1*gUxwSMsExhSL_rF1AGKEPA.png" /></figure><p>Here as we want to display a graph we need to call the dash core component “Graph”. The Graph id use the same principe as we used to identify buttons in the callback function, if we need to change the graph when we make an action. Figure parameter contains all the graph informations such as the data represented by a list of values and the labels associated to it, but also the graph type etc. Feel free to modify anything you want to suit your needs.</p><p>You can find all types of graphs <a href="https://plot.ly/python/">here</a>.</p><pre>pie = dcc.Graph(<br>        id = &quot;pieGraph&quot;,<br>        figure = {<br>          &quot;data&quot;: [<br>            {<br>              &quot;values&quot;: [800, 345, 500],<br>              &quot;labels&quot;: [<br>                &quot;Positive&quot;,<br>                &quot;Negative&quot;,<br>                &quot;Neutral&quot;<br>              ],<br>              &quot;name&quot;: &quot;Sentiment&quot;,<br>              &quot;hoverinfo&quot;:&quot;label+name+percent&quot;,<br>              &quot;hole&quot;: .7,<br>              &quot;type&quot;: &quot;pie&quot;<br>              &quot;marker&quot; : dict(colors[&#39;#05C7F2&#39;,&#39;#D90416&#39;,&#39;#D9CB04&#39;])</pre><pre>}],<br>          &quot;layout&quot;: {<br>                &quot;title&quot; : dict(text =&quot;Sentiment Analysis&quot;,<br>                               font =dict(<br>                               size=20,<br>                               color = &#39;white&#39;)),<br>                &quot;paper_bgcolor&quot;:&quot;#111111&quot;,<br>                &quot;width&quot;: &quot;2000&quot;,<br>                &quot;annotations&quot;: [<br>                    {<br>                        &quot;font&quot;: {<br>                            &quot;size&quot;: 20<br>                        },<br>                        &quot;showarrow&quot;: False,<br>                        &quot;text&quot;: &quot;&quot;,<br>                        &quot;x&quot;: 0.2,<br>                        &quot;y&quot;: 0.2<br>                    }<br>                ],<br>                &quot;showlegend&quot;: False</pre><pre>              }<br>        }<br>)</pre><pre>bar = dcc.Graph(<br>        id = &quot;3&quot;,<br>        figure ={<br>                  &quot;data&quot;: [<br>                  {<br>                          &#39;x&#39;:[&#39;Positive&#39;, &#39;Negative&#39;, &#39;Neutral&#39;],<br>                          &#39;y&#39;:[800, 345, 500],<br>                          &#39;name&#39;:&#39;SF Zoo&#39;,<br>                          &#39;type&#39;:&#39;bar&#39;,<br>                          &#39;marker&#39; :dict(color=[        &#39;#05C7F2&#39;,&#39;#D90416&#39;,&#39;#D9CB04&#39;]),<br>                  }],<br>                &quot;layout&quot;: {<br>                      &quot;title&quot; : dict(text =&quot;Overall Sentiments&quot;,<br>                                     font =dict(<br>                                     size=20,<br>                                     color = &#39;white&#39;)),<br>                      &quot;xaxis&quot; : dict(tickfont=dict(<br>                          color=&#39;white&#39;)),<br>                      &quot;yaxis&quot; : dict(tickfont=dict(<br>                          color=&#39;white&#39;)),<br>                      &quot;paper_bgcolor&quot;:&quot;#111111&quot;,<br>                      &quot;plot_bgcolor&quot;:&quot;#111111&quot;,<br>                      &quot;width&quot;: &quot;2000&quot;,<br>                      #&quot;grid&quot;: {&quot;rows&quot;: 0, &quot;columns&quot;: 0},<br>                      &quot;annotations&quot;: [<br>                          {<br>                              &quot;font&quot;: {<br>                                  &quot;size&quot;: 20<br>                              },<br>                              &quot;showarrow&quot;: False,<br>                              &quot;text&quot;: &quot;&quot;,<br>                              &quot;x&quot;: 0.2,<br>                              &quot;y&quot;: 0.2<br>                          }<br>                      ],<br>                      &quot;showlegend&quot;: False</pre><pre>                  }<br>              }<br>)</pre><p>Now that we finished designing graphs, we have to create the second row of the dashboard and pass all the contents to our app layout. Feel free to create as many graphs as you need in the second row.</p><pre>graphRow1 = dbc.Row([dbc.Col(pie, md=6), dbc.Col(bar, md=6)])</pre><pre>app.layout = html.Div([navbar,html.Br(),graphRow0, html.Br(), graphRow1], style={&#39;backgroundColor&#39;:&#39;black&#39;})</pre><h3>In conclusion</h3><p>During this read we learned about :</p><ol><li>How to use the dash core/bootstrap components such as graph, row, col.</li><li>How to make a callback function.</li><li>How to make our dashboard responsive.</li><li>How to create beautiful graph using Plotly.</li></ol><p>Thanks for reading, I hope I’ve helped you to understand further how the Python Dash framework works. Sorry if you have seen mistakes in my english I’m not native english speaker.</p><p><a href="https://www.linkedin.com/in/acacio-leclercqz/">My linkedin</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7bd0ea986f6" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>