<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Hamdy Abou El Anein</title>
    <description>The latest articles on DEV Community by Hamdy Abou El Anein (@hamdyaea).</description>
    <link>https://dev.to/hamdyaea</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F315649%2Fa70dee30-8974-46ea-86e5-6b6d6ea47a03.jpeg</url>
      <title>DEV Community: Hamdy Abou El Anein</title>
      <link>https://dev.to/hamdyaea</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/hamdyaea"/>
    <language>en</language>
    <item>
      <title>Bringing Early Linux Kernels to the Browser: Building Linux Time Machine</title>
      <dc:creator>Hamdy Abou El Anein</dc:creator>
      <pubDate>Sun, 22 Nov 2026 12:38:55 +0000</pubDate>
      <link>https://dev.to/hamdyaea/bringing-early-linux-kernels-to-the-browser-building-linux-time-machine-55jh</link>
      <guid>https://dev.to/hamdyaea/bringing-early-linux-kernels-to-the-browser-building-linux-time-machine-55jh</guid>
      <description>&lt;p&gt;Bringing Early Linux Kernels to the Browser: Building Linux Time Machine&lt;/p&gt;

&lt;p&gt;Exploring Linux history through x86 emulation, historical kernels, WebAssembly, and interactive browser environments.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F1a13ya3yuygpsokkck92.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F1a13ya3yuygpsokkck92.png" alt=" " width="800" height="420"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Why I Built Linux Time Machine&lt;/p&gt;

&lt;p&gt;I’ve been working with Linux professionally for more than 15 years. During that time, I’ve watched the ecosystem evolve through major changes in system administration, virtualization, containers, cloud infrastructure, and kernel development.&lt;/p&gt;

&lt;p&gt;But I’ve always been fascinated by where it all began.&lt;/p&gt;

&lt;p&gt;What did Linux actually look like in 1991? How different was an early Slackware installation from a modern Linux distribution? And could those environments be made accessible directly in a modern browser?&lt;/p&gt;

&lt;p&gt;These questions inspired me to build Linux Time Machine, an open-source project that lets visitors explore the evolution of Linux from its earliest releases to today.&lt;/p&gt;

&lt;p&gt;The project is available here:&lt;/p&gt;

&lt;p&gt;Live website: &lt;a href="https://linuxtimemachine.org/" rel="noopener noreferrer"&gt;https://linuxtimemachine.org/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Source code: &lt;a href="https://github.com/hamdyaea/linux-time-machine" rel="noopener noreferrer"&gt;https://github.com/hamdyaea/linux-time-machine&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;My goal wasn’t simply to create a timeline containing screenshots and historical descriptions. I wanted visitors to interact with Linux history, using historical x86 guest environments where possible and educational recreations for later milestones.&lt;/p&gt;

&lt;p&gt;That distinction is important because a simulated terminal is not the same as a running historical Linux kernel.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Linux 0.01: Going Back to 1991&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Linux 0.01 was released by Linus Torvalds in September 1991.&lt;/p&gt;

&lt;p&gt;It was an experimental kernel targeting Intel 386 hardware, not a complete Linux distribution with the features we expect today.&lt;/p&gt;

&lt;p&gt;It existed in a very different technical environment:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Early 32-bit x86 hardware.&lt;/li&gt;
&lt;li&gt;Limited memory and disk resources.&lt;/li&gt;
&lt;li&gt;A MINIX-compatible filesystem.&lt;/li&gt;
&lt;li&gt;No modern Linux desktop.&lt;/li&gt;
&lt;li&gt;An early system-call interface and process scheduler.&lt;/li&gt;
&lt;li&gt;Toolchains and boot assumptions very different from those used today.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;One of the first challenges was finding a reproducible way to build and execute a Linux 0.01-derived kernel using modern development tools.&lt;/p&gt;

&lt;p&gt;For the experimental build workflow, I used the compatibility-patched Linux 0.01 project maintained at:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/joeangel/linux-0.01" rel="noopener noreferrer"&gt;https://github.com/joeangel/linux-0.01&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The first stage involves building the historical kernel and checking its behavior in QEMU.&lt;/p&gt;

&lt;p&gt;However, successfully booting a kernel in QEMU doesn’t automatically mean it will work in a browser-based emulator.&lt;/p&gt;

&lt;p&gt;That leads to the next challenge.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Running x86 Linux Inside a Browser&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;For browser emulation, Linux Time Machine uses v86:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/copy/v86" rel="noopener noreferrer"&gt;https://github.com/copy/v86&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;v86 is an open-source x86 emulator designed to run PC software inside a web browser, with WebAssembly support.&lt;/p&gt;

&lt;p&gt;Instead of requiring users to install a traditional virtualization application, the browser loads the emulator and its virtual machine resources.&lt;/p&gt;

&lt;p&gt;The relevant components include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The v86 JavaScript runtime.&lt;/li&gt;
&lt;li&gt;The v86 WebAssembly binary.&lt;/li&gt;
&lt;li&gt;SeaBIOS and VGA BIOS.&lt;/li&gt;
&lt;li&gt;Historical boot media.&lt;/li&gt;
&lt;li&gt;Virtual hard-disk images.&lt;/li&gt;
&lt;li&gt;Browser code that configures and controls the virtual machine.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A simplified view of the architecture looks like this:&lt;/p&gt;

&lt;p&gt;Browser interface → v86 emulator → emulated x86 hardware → historical boot media → Linux kernel and userspace&lt;/p&gt;

&lt;p&gt;The historical operating system runs within the emulated environment. The browser supplies the display, keyboard interaction and other supporting functionality.&lt;/p&gt;

&lt;p&gt;This is fundamentally different from rendering a command prompt with JavaScript.&lt;/p&gt;

&lt;p&gt;The boot problem&lt;/p&gt;

&lt;p&gt;Early Linux kernels weren’t designed around all the conventions used by modern bootloaders.&lt;/p&gt;

&lt;p&gt;For example, the Linux 0.01 Image produced by the compatibility build is not automatically a modern Linux boot-protocol bzImage.&lt;/p&gt;

&lt;p&gt;The browser configuration therefore needs appropriate boot media and a compatible disk layout.&lt;/p&gt;

&lt;p&gt;In my 1991 configuration, the project uses a boot floppy, an IDE root disk and an additional placeholder IDE master device. That placeholder is needed by the emulator configuration to expose the historical disk on the expected IDE channel.&lt;/p&gt;

&lt;p&gt;This is the type of detail that makes historical emulation more involved than simply loading a disk image into a virtual machine.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Moving Forward to Slackware and Red Hat&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Linux changed considerably during the 1990s.&lt;/p&gt;

&lt;p&gt;By 1993, distributions such as Slackware were assembling the Linux kernel, user-space utilities and installation tools into usable systems.&lt;/p&gt;

&lt;p&gt;Linux Time Machine includes browser guest configurations for several historical milestones:&lt;/p&gt;

&lt;p&gt;Era Environment Guest memory configuration&lt;br&gt;
1991    Compatibility-patched Linux 0.01    8 MiB&lt;br&gt;
1993    Linux 0.99.12 / Slackware 1.01  16 MiB&lt;br&gt;
1998    Red Hat 5.2 64 MiB&lt;br&gt;
2004    Ubuntu-era environment  128 MiB&lt;/p&gt;

&lt;p&gt;The 1991 and 1993 configurations use compatibility-modified historical kernels. The 1998 configuration uses a historical Red Hat disk image.&lt;/p&gt;

&lt;p&gt;The 2004 environment is an Ubuntu-era recreation and should not be confused with an unchanged original Ubuntu 4.10 installation.&lt;/p&gt;

&lt;p&gt;Each period introduces different considerations involving boot devices, storage, memory, display and operating-system compatibility.&lt;/p&gt;

&lt;p&gt;My objective is to preserve the technical character of these environments while making them easier to explore.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;A Practical Problem: Hosting Historical Disk Images&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;One of the more interesting engineering challenges had nothing to do with rendering the interface.&lt;/p&gt;

&lt;p&gt;It was the size of the disk images.&lt;/p&gt;

&lt;p&gt;The website is hosted using Cloudflare Pages, which imposes a size limit on individual static assets.&lt;/p&gt;

&lt;p&gt;Some historical disk images exceed that limit.&lt;/p&gt;

&lt;p&gt;Instead of removing the disk images or replacing them with simulated terminals, I developed a packaging process that prepares the virtual disks for browser delivery.&lt;/p&gt;

&lt;p&gt;For selected historical guests, the process works as follows:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Prepare the historical disk using QEMU tooling.&lt;/li&gt;
&lt;li&gt;Convert the virtual disk to a raw image where required.&lt;/li&gt;
&lt;li&gt;Compress the image using gzip.&lt;/li&gt;
&lt;li&gt;Split the compressed image into smaller static files.&lt;/li&gt;
&lt;li&gt;Publish the parts alongside the emulator.&lt;/li&gt;
&lt;li&gt;Download and reassemble the compressed stream in the browser.&lt;/li&gt;
&lt;li&gt;Decompress the image using the browser’s DecompressionStream API.&lt;/li&gt;
&lt;li&gt;Provide the resulting virtual disk to v86.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;In the packaging scripts, compressed images are split into 20 MiB parts to stay below the static hosting limit.&lt;/p&gt;

&lt;p&gt;The browser also performs basic checks on downloaded resources. For example, it verifies that an expected emulator asset hasn’t accidentally been replaced by an HTML error page.&lt;/p&gt;

&lt;p&gt;For the larger 2004 environment, the implementation instead uses a remote virtual disk endpoint designed for asynchronous disk access.&lt;/p&gt;

&lt;p&gt;This avoids packaging the entire disk into the Cloudflare Pages static deployment.&lt;/p&gt;

&lt;p&gt;These storage decisions are not very visible to visitors, but they are important for making the experience work.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Historical Emulation Versus Educational Reconstruction&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;I wanted to avoid a common problem with retro-computing demonstrations: presenting a modern simulation as if it were an original historical operating system.&lt;/p&gt;

&lt;p&gt;Linux Time Machine therefore combines two different approaches.&lt;/p&gt;

&lt;p&gt;Historical x86 environments&lt;/p&gt;

&lt;p&gt;For selected early milestones, the project configures v86 to execute historical guest environments using boot media and disk images.&lt;/p&gt;

&lt;p&gt;The repository contains the browser integration, while the larger guest binaries and disks are packaged separately for deployment.&lt;/p&gt;

&lt;p&gt;Educational recreations&lt;/p&gt;

&lt;p&gt;For later milestones, the project offers interactive terminal and desktop recreations illustrating changes in Linux history.&lt;/p&gt;

&lt;p&gt;These are browser-based educational interfaces, not original historical operating systems executing their original kernels.&lt;/p&gt;

&lt;p&gt;A displayed kernel version or a simulated uname response does not prove that a genuine kernel is running.&lt;/p&gt;

&lt;p&gt;For me, keeping that distinction clear is part of respecting the technical history of Linux.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Building the Interface Without a Heavy Framework&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The web interface uses a relatively straightforward stack:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;HTML5.&lt;/li&gt;
&lt;li&gt;CSS3.&lt;/li&gt;
&lt;li&gt;Vanilla JavaScript.&lt;/li&gt;
&lt;li&gt;WebAssembly through v86.&lt;/li&gt;
&lt;li&gt;Cloudflare Pages for hosting.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The interface includes an interactive timeline, a terminal, historical explanations and a retro-futuristic time-machine design.&lt;/p&gt;

&lt;p&gt;Visitors can select an era and explore how the Linux ecosystem changed over the decades.&lt;/p&gt;

&lt;p&gt;On mobile devices, where running a complete historical x86 guest may not be practical, the project provides an interactive command experience instead.&lt;/p&gt;

&lt;p&gt;This lets users explore the history without requiring an emulator to execute on every device.&lt;/p&gt;

&lt;p&gt;The project is designed to be accessible without installing software locally.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;What I Learned&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Working on Linux Time Machine has highlighted several important lessons.&lt;/p&gt;

&lt;p&gt;Old software exposes assumptions we rarely think about today.&lt;/p&gt;

&lt;p&gt;Boot protocols, disk geometry, hardware interfaces and kernel expectations have changed significantly over the decades.&lt;/p&gt;

&lt;p&gt;Emulation doesn’t eliminate compatibility problems.&lt;/p&gt;

&lt;p&gt;Even when an emulator reproduces x86 hardware, the kernel and its userspace must still work with the emulated devices and boot configuration.&lt;/p&gt;

&lt;p&gt;Hosting is part of systems engineering.&lt;/p&gt;

&lt;p&gt;File-size limits, compression, disk streaming and memory usage can determine whether a browser-based virtual machine is practical.&lt;/p&gt;

&lt;p&gt;Historical accuracy matters.&lt;/p&gt;

&lt;p&gt;Compatibility patches can be necessary, but those changes should be documented. Educational recreations should be identified rather than presented as original systems.&lt;/p&gt;

&lt;p&gt;And perhaps most importantly, making old technology interactive can be a useful way to teach how modern systems evolved.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Open Source and Future Development&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Linux Time Machine is available as an open-source project under the MIT license. Historical third-party software, disk images and emulator components retain their respective licenses.&lt;/p&gt;

&lt;p&gt;The public GitHub repository contains the website source, emulator integration and technical documentation.&lt;/p&gt;

&lt;p&gt;Large historical disk images and emulator binaries are packaged separately, so cloning the repository alone does not reproduce every deployed virtual machine.&lt;/p&gt;

&lt;p&gt;Some areas I’d like to continue improving include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Compatibility with additional early Linux releases.&lt;/li&gt;
&lt;li&gt;More reproducible historical kernel boot environments.&lt;/li&gt;
&lt;li&gt;Better integration between the timeline and the emulator.&lt;/li&gt;
&lt;li&gt;Additional historical distributions.&lt;/li&gt;
&lt;li&gt;Improved educational explanations of kernel evolution.&lt;/li&gt;
&lt;li&gt;Testing and documentation across different browsers.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I would especially welcome feedback from people interested in kernel development, old Linux distributions, x86 emulation and retro-computing.&lt;/p&gt;

&lt;p&gt;Try Linux Time Machine&lt;/p&gt;

&lt;p&gt;If you’re interested in exploring Linux history, you can try the project directly:&lt;/p&gt;

&lt;p&gt;Website: &lt;a href="https://linuxtimemachine.org/" rel="noopener noreferrer"&gt;https://linuxtimemachine.org/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;GitHub: &lt;a href="https://github.com/hamdyaea/linux-time-machine" rel="noopener noreferrer"&gt;https://github.com/hamdyaea/linux-time-machine&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Project video: &lt;a href="https://youtu.be/GdhBmuVOcXc" rel="noopener noreferrer"&gt;https://youtu.be/GdhBmuVOcXc&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Technical boot documentation: &lt;a href="https://github.com/hamdyaea/linux-time-machine/blob/main/docs/REAL_KERNEL_BOOT.md" rel="noopener noreferrer"&gt;https://github.com/hamdyaea/linux-time-machine/blob/main/docs/REAL_KERNEL_BOOT.md&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you have experience with early Linux kernels or historical distributions, I’d be interested to hear your thoughts.&lt;/p&gt;

&lt;p&gt;Which Linux release or distribution would you like to revisit in a modern browser?&lt;/p&gt;

&lt;p&gt;⸻&lt;/p&gt;

&lt;p&gt;About the author: Hamdy Abou El Anein is a senior Linux systems engineer and open-source developer based in Switzerland, with more than 15 years of professional experience working with Linux systems.&lt;/p&gt;

</description>
      <category>linux</category>
      <category>opensource</category>
      <category>webdev</category>
      <category>showdev</category>
    </item>
    <item>
      <title>Mastering Bash arguments with getopts</title>
      <dc:creator>Hamdy Abou El Anein</dc:creator>
      <pubDate>Sun, 06 Mar 2022 10:48:34 +0000</pubDate>
      <link>https://dev.to/hamdyaea/mastering-bash-arguments-with-getopts-iac</link>
      <guid>https://dev.to/hamdyaea/mastering-bash-arguments-with-getopts-iac</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;In this article, I show you how to mastering the Bash arguments with getopts to have a software who run with professional arguments like &lt;/p&gt;

&lt;pre&gt;mysoft.bsh -f [arg1] -g [arg2]
&lt;/pre&gt;

&lt;p&gt;I also show you how to add a default value if the argument is not given.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Here's an example of code :&lt;/p&gt;

&lt;pre&gt;f=10  
g=5  
while getopts ":f:g:" option; do  
    case "${option}" in  
        f)  
            f=${OPTARG}  
            ((f == 15 || f == 75)) || usage  
            ;;  
        g)  
            g=${OPTARG}  
            ;;  
        *)  
            usage
            ;;
    esac  
done  
shift $((OPTIND-1))  
if [ -z "${v}" ] || [ -z "${g}" ]; then  
    echo "info"  
fi  
echo "f = ${f}"  
echo "g = ${g}"
&lt;/pre&gt;

&lt;p&gt;Now we can look at the code more closely :&lt;/p&gt;

&lt;p&gt;Here we declare a default value to the variable -v and -g&lt;/p&gt;

&lt;pre&gt;f=10  
g=5
&lt;/pre&gt;

&lt;p&gt;Here we use getopts with the arguments -f -g. If the user write, software.bsh -f value1 and/or -g value 2.&lt;/p&gt;

&lt;pre&gt;while getopts ":f:g:" option; do  
    case "${option}" in  
        f)  
            f=${OPTARG}  
            ((f == 15 || f == 75)) || usage  
            ;;  
        g)  
            g=${OPTARG}  
            ;;  
        *)  
            usage
            ;;
    esac  
done
&lt;/pre&gt;

&lt;p&gt;That makes the arguments in Bash more professional.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--_adY5WNd--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wdlosftc320v94zw46x2.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--_adY5WNd--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wdlosftc320v94zw46x2.jpg" alt="Image description" width="400" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>bash</category>
      <category>linux</category>
      <category>arg</category>
      <category>getopts</category>
    </item>
    <item>
      <title>Create a login page in Python with flask and/or gunicorn   💻 🐍 </title>
      <dc:creator>Hamdy Abou El Anein</dc:creator>
      <pubDate>Sat, 05 Feb 2022 18:59:48 +0000</pubDate>
      <link>https://dev.to/hamdyaea/create-a-login-page-with-in-python-with-flask-andor-gunicorn-1g5a</link>
      <guid>https://dev.to/hamdyaea/create-a-login-page-with-in-python-with-flask-andor-gunicorn-1g5a</guid>
      <description>&lt;p&gt;In this post I will show you how to create a simple login page in Python with the flask library and finally with gunicorn.&lt;/p&gt;

&lt;p&gt;let's begin!&lt;/p&gt;

&lt;p&gt;Create the virtual env:&lt;/p&gt;

&lt;p&gt;in the project directory :&lt;/p&gt;

&lt;p&gt;&lt;code&gt;python3 -m venv myenv&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Then the linux command to activate the new env:&lt;br&gt;
&lt;code&gt;source /myenv/bin/activate&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Now we are in our dev env.&lt;/p&gt;

&lt;p&gt;From here install the flask library :&lt;/p&gt;

&lt;p&gt;&lt;code&gt;pip install flask&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Now we can start to develop our flask app.&lt;/p&gt;

&lt;p&gt;Create a file that you can call &lt;code&gt;mylogin.py&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;In this file :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#!/usr/bin/env python3

from flask import Flask, render_template, redirect, url_for, request

app = Flask(__name__)

@app.route('/', methods=['GET', 'POST'])
def login():
    error = None
    if request.method == 'POST':
        if request.form['username'] == 'Admin' and request.form['password'] == 'Admin1234$':
            return render_template("adminpage.html")
        elif request.form['username'] == 'User' and request.form['password'] == 'User1234$':
            return render_template("adminpage.html")
        else:
            return 'Invalid login or password, please try again'

    return render_template('login.html', error=error)


if __name__=='__main__':
    app.run(host='0.0.0.0')
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We have created two users :&lt;/p&gt;

&lt;p&gt;name: &lt;strong&gt;Admin&lt;/strong&gt;&lt;br&gt;
password : &lt;strong&gt;Admin1234$'&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;and &lt;/p&gt;

&lt;p&gt;name: &lt;strong&gt;User&lt;/strong&gt;&lt;br&gt;
password: &lt;strong&gt;User1234$&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;mkdir templates&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;in templates, we will create 3 files :&lt;/p&gt;

&lt;p&gt;adminpage.html  login.html  userpage.html&lt;/p&gt;

&lt;p&gt;&lt;code&gt;login.html&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;html&amp;gt;
&amp;lt;head&amp;gt;
&amp;lt;title&amp;gt;Login page&amp;lt;/title&amp;gt;
&amp;lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;
    &amp;lt;div class="container"&amp;gt;
        &amp;lt;h1&amp;gt;Please login&amp;lt;/h1&amp;gt;
        &amp;lt;br&amp;gt;
        &amp;lt;form action="" method="post"&amp;gt;
            &amp;lt;input type="text" placeholder="Username" name="username" value="{{  request.form.username }}"&amp;gt;
            &amp;lt;input type="password" placeholder="Password" name="password" value="{{  request.form.password  }}"&amp;gt;
            &amp;lt;input class="btn btn-default" type="submit" value="Login"&amp;gt;
        &amp;lt;/form&amp;gt;
        {% if error %}
            &amp;lt;p class="error"&amp;gt;&amp;lt;strong&amp;gt;Error:&amp;lt;/stong&amp;gt;  {{  error }}
        {% endif %}
    &amp;lt;/div&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;adminpage.html&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;h1&amp;gt;This is the admin private page&amp;lt;/h1&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;userpage.html&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;h1&amp;gt;&amp;gt;This is the user private page&amp;lt;/h1&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now you can test it with flask:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;python mylogin.py&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;The app is running...&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; * Serving Flask app 'mylogin' (lazy loading)
 * Environment: development
 * Debug mode: on
 * Running on all addresses.
   WARNING: This is a development server. Do not use it in a production deployment.
 * Running on http://YOUR.IP:5000/ (Press CTRL+C to quit)
 * Restarting with stat
 * Debugger is active!
 * Debugger PIN: 521-493-757
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now open a web browser and connect to your ip : &lt;a href="http://YOUR.IP:5000/" rel="noopener noreferrer"&gt;http://YOUR.IP:5000/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you have a firewall installed, the port 5000 must be open.&lt;/p&gt;

&lt;p&gt;You can now try to login with the admin the with the user account.&lt;/p&gt;

&lt;p&gt;Now we can make it run for production with gunicorn :&lt;/p&gt;

&lt;p&gt;install gunincorn:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;pip install gunicorn&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;in the main directory, we need to create a file called :&lt;/p&gt;

&lt;p&gt;&lt;code&gt;wsgi.py&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from mylogin import app

if __name__=='__main__':
    app.run()

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here mylogin is our mylogin.py Python/Flask app.&lt;/p&gt;

&lt;p&gt;Now we can run it with gunicorn :&lt;/p&gt;

&lt;p&gt;&lt;code&gt;gunicorn --bind 0.0.0.0:5000 wsgi:app&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;It's running well...&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[2022-02-05 19:51:48 +0100] [6545] [INFO] Starting gunicorn 20.1.0
[2022-02-05 19:51:48 +0100] [6545] [INFO] Listening at: http://0.0.0.0:5000 (6545)
[2022-02-05 19:51:48 +0100] [6545] [INFO] Using worker: sync
[2022-02-05 19:51:48 +0100] [6546] [INFO] Booting worker with pid: 6546
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Open again your web browser at the same address and it's running.&lt;/p&gt;

&lt;p&gt;The project directory is like this :&lt;/p&gt;

&lt;p&gt;&lt;code&gt;----Project-Directory-&amp;gt;    &lt;br&gt;
           |    &lt;br&gt;
           |    &lt;br&gt;
           --mylogin.py    &lt;br&gt;
           --wsgi.py    &lt;br&gt;
           |     &lt;br&gt;
           |     &lt;br&gt;
            ----Project-Directory-&amp;gt;----templates-&amp;gt;     &lt;br&gt;
                 |     &lt;br&gt;
                 |    &lt;br&gt;
                 --login.html    &lt;br&gt;
                 --userpage.html    &lt;br&gt;
                 --adminpage.html&lt;/code&gt;     &lt;/p&gt;

&lt;p&gt;Finally the library requirements in this project :&lt;/p&gt;

&lt;p&gt;requirements.txt&lt;/p&gt;

&lt;p&gt;&lt;code&gt;click==8.0.3&lt;br&gt;
Flask==2.0.2&lt;br&gt;
gunicorn==20.1.0&lt;br&gt;
itsdangerous==2.0.1&lt;br&gt;
Jinja2==3.0.3&lt;br&gt;
MarkupSafe==2.0.1&lt;br&gt;
Werkzeug==2.0.2&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhe3ao48k5i52kkthozgk.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhe3ao48k5i52kkthozgk.jpg" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>python</category>
      <category>flask</category>
      <category>gunicorn</category>
      <category>login</category>
    </item>
    <item>
      <title>How to find the N most present element in a list in Python 💻 🐍</title>
      <dc:creator>Hamdy Abou El Anein</dc:creator>
      <pubDate>Wed, 26 Jan 2022 10:53:11 +0000</pubDate>
      <link>https://dev.to/hamdyaea/how-to-find-the-n-most-present-element-in-a-list-in-python-5fej</link>
      <guid>https://dev.to/hamdyaea/how-to-find-the-n-most-present-element-in-a-list-in-python-5fej</guid>
      <description>&lt;p&gt;If you have a list in Python 🐍 and you need to find for example the 3 elements that are the must present in the list. &lt;/p&gt;

&lt;p&gt;You can do it like this :&lt;/p&gt;

&lt;p&gt;Create a list&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mylist = [1,2,3,4,4,4,4,5,5,6,7,8,8,8,9]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Create two variables, maxcount is the number N of elements that we are searching.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;count = 1
maxcount = 3

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Use a while loop to find what we are looking for :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;while count &amp;lt;= maxcount:
    num = max(set(mylist), key=mylist.count)
    print(num)
    count+=1
    while num in mylist:
        mylist.remove(num) #Here we remove the element that was the max
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now the full code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mylist = [1,2,3,4,4,4,4,5,5,6,7,8,8,8,9]

count = 1
maxcount = 3

while count &amp;lt;= maxcount:
    num = max(set(mylist), key=mylist.count)
    print(num)
    count+=1
    while num in mylist:
        mylist.remove(num)

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now the result is :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;4
8
5
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can even add them to a new list...&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--jb50Mx1R--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tlxjxrq036qhd4nte4o2.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--jb50Mx1R--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tlxjxrq036qhd4nte4o2.jpg" alt="Image description" width="300" height="168"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>python</category>
    </item>
  </channel>
</rss>
