[PYTHON] The infrastructure shop decided to develop "Web tools" as a theme. .. Until you think about the environment for creating "Web tools".

--Click here for the table of contents. Creating BINGO "Web Tools" with Python

It is an infrastructure shop that decided to develop "Web tools" for some reason. However, the infrastructure shop does not usually do development. That's why I started with a carefree feeling that I should try it. Therefore, please understand that we are very sorry for those who are devoting themselves to development in their daily work. I hope it will be helpful for beginners like me and those who want to try something.

Theme "Web Tools"

Let's make a "Web tool" with the given theme! was. The ** first wall ** is the "web tool". I don't understand the "Web tools" themselves. It's too vague. So I searched obediently. If you search for "What is a web tool" on google, it will be roughly

  1. A tool used when creating a website.
    --- HTML editor, image processing, authoring software, etc.
  2. Convenient things provided by accessing the website from a browser
    --- Is the IP address check or calendar that I often use applicable?
  3. Tools used to access the website
    --- Scraping, pods, etc.

If you think about it again, most of the things that have been created with Web + CGI for a long time are "Web tools"! I think. 1 is meaningful if it is difficult, but I rejected it because it is not an easy one that I can make by myself because I will use a tool that already exists. I wish I had the information I wanted to collect for my hobbies, but I couldn't think of 3 so far, so I rejected it. From the above options, I decided to think about "2. It is convenient to access and use the website with a browser".

Then, ** the second wall ** hits "what to make". ・ The energy to make something == I feel dissatisfied or inconvenient with something. Is it convenient to have it? (I don't want to get in the way.) I'm thinking, but I don't have much complaints these days, I don't have any hobbies ... Born in the Showa era, the Reiwa era has become convenient for me. Sometimes I give up because I can't help myself if I'm really dissatisfied.

However, I can't help making anything, so I decided to use the explanation at the gathering that triggered the "theme" as it is.

Make tools for bingo games

Bingo games are one of the means to scatter prizes, which is often held at parties, etc., and people with good luck ** can get luxurious prizes. I have no luck, so I always get a participation prize.

Every year, there is a bingo game tournament sponsored by the residents' association at a local festival, and the progress of the game was wonderfully "analog". (That's why it tastes good. It's pretty ugly.) As a dissatisfaction

What is a bingo game?

There were various explanations when searching the Wiki, but I think that the bingo games that are often played in Japan have the following specifications. (https://ja.wikipedia.org/wiki/%E3%83%93%E3%83%B3%E3%82%B4)

As an aside, it's up to the last "Bingo" to be the luck of the day, so for me, who has been particularly unlucky lately, it's a game where you can enjoy "How long will it be today?"

By the way, I found such a site (also a web tool). ** "Bingo Game End Time Simulator" ** https://coffee-ryo.devel.jp/app_Bingo.html

What you need for a bingo game

Now, let's think about "necessary + useful things" for bingo games as parts of web tools.

1. Lottery machine

Numbers 1 to 75 are randomly extracted. Since it does not overlap, it ends after extracting 75 times. With this alone, it seems that you can also create it with JavaScript.

2. Lottery result display

Display the numbers extracted by the lottery machine. Display in the order of extraction, display in a list for each group, etc. At the event party, I handwritten the extracted numbers on a white board or imitation paper, but I feel that it is not very helpful to the participants.

3. Bingo card and progress display

At parties, bingo cards are commercially available, but I think it's possible to make them randomly with web tools. If possible, I think it would be convenient to be able to read the image of the bingo card in the hands of the participants and register it. (I don't think we can reach that point this time, so let's ask the participants to enter it.) For the progress display, I want a function that displays the bingo cards entered by the participants based on the extraction results and can display reach and bingo.

4. Participant status display

It would be convenient if the name of the person in front of the current bingo or the person who became the bingo in the lottery could be displayed based on the card entered by the participants as the management side. If you make it, you can display it in various ways, but this time I think it would be good if you could know the number of people who bingoed and the number of people who reached.

What kind of environment do you make?

There are not many options for my development environment (physical aspect), so if you list the ones that do not need to be examined

Daily email confirmation, web browsing, and small excel can be edited, and you can sacrifice the image quality of videos. It is useful because it was a lightweight and long-time battery for that time.

"Web Tools" environment

I already have a browser (IE, Firefox, or whatever) because it's "convenient to access and use a website with a browser" that I chose to create the subject "Web Tools". Next, you need to prepare a website = web server as what you need. Is Web server = Apache a thing of the past? Even if you want to make a little web tool, you can build a Linux server, put Apache in it, set it up, write HTML, and write CGI, which will reduce your motivation.

Nowadays, a web framework that runs on Python has been created, and it seems that there are typically the following. Reference: Complete version of the 2019 Python Recommended Framework! Thorough comparison of each framework!

If you think about work and learn, the priority will be from the top. But should we start learning spectacular features for this subject? No, why don't we do it? I thought about it, but this time I decided to choose the lightweight "Flask" because the development environment (physics) is poor.

About Flask

I was immediately taken care of by Google teacher.

I think I'll let you refer to such things.

Also, in a book Python 3 skill improvement textbook supervised by Python Engineer Development Promotion Association I would like to do my best by making full use of.

Grab the image of using Flask

Knowing the Apache web server made the Flask web server image look awkward.

With an Apache web server ...

Apache responds to the request, reads and executes the required HTML and CGI, and returns the result to the browser. Since the data disappears when one request is completed, it was necessary to separately consider how to retain the data. (Is it okay to be stateless?)

With Flask's web server ...

Create to handle requests from the Web in the Ptyhon execution application. Change the processing content with the URL of the request, attract HTML / CSS and return it to the browser. Since the Ptyhon app is running, it feels like the data being processed can be taken over as it is.

So, next time I plan to build an environment. --Note that Python + Flask + α is installed on windows10 (32bit)

--Click here for the table of contents. Creating BINGO "Web Tools" with Python

Recommended Posts

The infrastructure shop decided to develop "Web tools" as a theme. .. Until you think about the environment for creating "Web tools".
(Memo) Until you extract only the part you want from a certain Web page, convert it to a Sphinx page, and print it as a PDF
Think about the analysis environment (Part 1: Overview) * As of January 2017
When you want to keep the Sphinx documentation theme as usual
[AtCoder for beginners] A story about the amount of calculation that you want to know very roughly