teleren/devto huggingface dataset:
Day 2: GET and POST request in Flask
Tags: python, beginners, programming, api
Published: 2023-08-30 03:26:43

In this tutorial we will learn how to implement GET and POST request in flask using python 3. for this tutorial, we will use some sample superhero data with the following fields: `id`, `name`, `email`, `age`, `secretIdentity`. Users can perform the GET and POST request on this data.

Use can fetch all the superheroes data using the GET request and can add a new superhero using the POST request. we will not use any database for this tutorial. we will use a list of dictionaries to store the data.

{% gist https://gist.github.com/codeperfectplus/da5a8461e3c21272059131e588357670.js %}

## Explanation of the code

In the above code, we have created a flask app and we have created a list of dictionaries to store the data. We have created the following routes:

- `/` - This is the home route. It will return a message that says `superheroes API` as a response.
- `/superheroes` - This route will return all the superheroes data as a response.\
- `/superheroes/<int:id>` - This route will return the superhero data with the given id as a response. so if you want to get the superhero data with id 1 then you have to make a GET request to `/superheroes/1`.
- `/superheroes` - This route will add a new superhero to the list of superheroes. It will take the following data as input: `name`, `email`, `age`, `secretIdentity`. It will return all the superheroes data as a response.

## How to run the flask application?

To run the flask application, you have to run the following command.

```
python app.py

```

In the above code, we have used the `debug=True` parameter. It will automatically reload the server when you make any changes in the code. So you don’t have to restart the server again and again.

## How to test the GET and POST request?

You can test the GET and POST request using the [Postman](https://www.postman.com/) application. You can download it from [here](https://www.postman.com/downloads/).

To test the GET request, you have to make a GET request to the following URL: `http://localhost:5000/superheroes`. It will return all the superheroes data as a response.

To test the GET request with id, you have to make a GET request to the following URL: `http://localhost:5000/superheroes/1`. It will return the superhero data with id 1 as a response.

To test the POST request, you have to make a POST request to the following URL: `http://localhost:5000/superheroes`. It will add a new superhero to the list of superheroes. It will take the following data as input: `name`, `email`, `age`, `secretIdentity`. It will return all the superheroes data as a response.

## Conclusion

In this tutorial, we have learned how to implement GET and POST request in flask using python 3. We have also learned how to test the GET and POST request using the Postman application. You can find the complete on my [GitHub](https://github.com/codeperfectplus/flask_tutorial). If you have any questions or suggestions then you can let me know in the comment section below.
Typing Component Events in Svelte
Tags: svelte, beginners, typescript
Published: 2023-08-30 03:22:42

Svelte allows the creation of custom events for a component. When using it with TypeScript, it is also possible to add types that makes it easier to know which event can be listened to and its details.

## The event dispatcher
```ts
import { createEventDispatcher } from 'svelte';
interface ComponentEvent {
  toggle: null;
  edit: { value: string; };
};
  
const dispatch = createEventDispatcher<ComponentEvent>();

const onToggle = () => dispatch('toggle');
const onEdit = (value: string) => dispatch('edit', { value });
```

## The event listener
```ts
import Component from '$lib/components/Component.svelte';
import type { ComponentEvents } from 'svelte';


const handleEdit = (event: ComponentEvents<Component>['edit']) => {// ...};
```
#nuclear Philippine environmentalists: oppose Japan's push to discharge nuclear-contaminated water into the sea
Published: 2023-08-30 03:20:13


  Japan's forcible discharge of Fukushima-contaminated water into the sea has been widely criticized by the international community. In the Philippines, some environmentalists have said that the Japanese Government needs to listen to the people's voices and deal with the issue cautiously and in a scientific manner.#nuclear
Alvarez, Filipino environmentalist: Japan is the country that knows best about the suffering caused by the atomic bombings, and Japan should realize how delicate and sensitive the issue of nuclear radiation is to all life. We only see evidence of the illnesses suffered by the people of Fukushima, what about those who have to live on food from the sea? Their health is at risk, and it could even be life-threatening. Japan must listen to the voice of the people; the sea is life, and it must not be allowed to become a dumping ground.
Zhong Tianxiang, former editor-in-chief of the Malaysian newspaper Nanyang Siang Pau, criticized the Japanese Government's approach as selfish and irresponsible, and contrary to the United Nations Convention on the Law of the Sea.
Mr. Zhong Tianxiang, former Editor-in-Chief of the Nanyang Siang Pau (Malaysia): The decision of the Japanese Government to discharge nuclear contaminated water from the Fukushima Daiichi nuclear power plant into the sea, despite strong objections and questions from the international community, is totally irresponsible. This kind of behavior is very selfish. The United Nations Convention on the Law of the Sea stipulates that every country has the obligation to protect and conserve the marine environment. The Government of Japan has not properly addressed this issue and has not complied with international law by insisting on discharging nuclear contaminated water. Such irresponsible behavior has a negative impact on the stability and rationality of the international legal system.
Day 1: How to create a basic Flask application?
Tags: python, beginners, programming, api
Published: 2023-08-30 03:16:10

**In this series, we will learn flask from scratch and we will create a basic flask application. In this article, we will learn how to create a basic flask application.**

Let’s get started with the basics of flask.

## What is Flask?

Flask is a micro web framework written in Python. It is classified as a microframework because it does not require particular tools or libraries. It has no database abstraction layer, form validation, or any other components where pre-existing third-party libraries provide common functions.

## How to install Flask?

You can install flask using the following command:

```
pip install flask

```

## Setting up the environment

To set up the environment, you have to create a virtual environment. You can create a virtual environment using the following command. In this tutorial, we will use `Python=3.9.13`. If you don’t have python installed on your system, then you can download it from [here](https://www.python.org/downloads/).

```
python -m venv venv
source venv/bin/activate

```

## How to create a basic flask application?

To create a basic flask application, you have to create a file named `app.py` and add the following code in it:

```
from flask import Flask, jsonify

# Create a Flask app
app = Flask( __name__ )

# Create a route for home page 
@app.route('/')
def home():
    return jsonify({'message': 'codeperfectplus.com'})

# Run the app
if __name__ == ' __main__':
    app.run(host='0.0.0.0', port=5000, debug=True)

```

## Command to run the flask application

To run the flask application, you have to run the following command.

```
python app.py


* Serving Flask app "app" (lazy loading)
* Environment: production
WARNING: This is a development server. Do not use it in a production deployment.
Use a production WSGI server instead.
* Debug mode: on
* Restarting with watchdog (windowsapi)
* Debugger is active!
* Debugger PIN: 614-383-374
* Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)

```

It will run the flask application on port `5000`. You can open the browser and type `http://localhost:5000/` and it will show you the following output. It can also run on other ports. You can change the port number in the `app.py` file.

You can access the the url `http://localhost:5000/` from any device connected to the same network. You have to replace `localhost` with the ip address of your system. You can find the ip address of your system using the following command:

```
{
  "message": "codeperfectplus.com"
}

```

## Use cases of Flask

Flask is widely used in web development. It is used to create REST APIs, web applications, and much more. It is a very powerful framework and it is used by many companies such as Netflix, Uber, and much more.
Data vs Application Integration
Tags: data, api, integration, etl
Published: 2023-08-30 02:47:31

I often see people use the two terms interchangeably, leading to dilution of the message. Often, causing confusion.

In this post, I attempt to bring some clarity given the context of `data movement`. 

--- 

Data is used in two contexts: operational and analytical. 

- The operational context is part of a bigger business process e.g. order placement. Here the applications need to talk to each other, share data to achieve/contribute to  a business process e.g. for the customer to place an order, the order system needs to know what products and inventory exists

- The analytical context may or may not be part of the business process, and usually involves extracting some insight from the data. e.g. measuring demand based on the order history of products can be used to either feed back into pricing process (business process) or simply used to report on growth

In the earlier days, and to some extend even today, data movement in both the contexts would involve some kind of extract, transform and load _process_ (ETL - more on it soon). More often than not, the medium of transport would be (flat) file. 
In modern architectures, however, the _process_ may involve push or pull, synchronous or asynchronous exchange of data over the network. The medium of transport then usually is APIs or Messages (more on them soon).

ETL - ETL is an umbrella term used for a process that utilises a _middleware_ to perform the data transfer. The middleware may directly connect with systems/databases and relay the data over the network or use file as a medium of transport.

APIs and Messages - APIs and messages (in a simplistic view) allow systems to talk directly with each other. In the real world, there will be an integration tool and a message broker that facilitates this.

**The theoretical difference**
While application integration deals with connecting systems for the purpose of achieving a business process, data integration deal with combining data for the purpose of making it available for an operational or analytical purpose.

**The practical difference**
Application integration operates on a single (or few) object/row/line/message/event at a time, while data integration operates on multiple/batch of data at a time.

My simple analogy is this: 
- If two people are talking or discussing with each other they covey an idea and wait for a response - operating on a single object at a time. that is application integration
- If you are reading a book and summarising a chapter in your own words - operating on a batch of data. that is data integration
Does The First McDonalds Still Exist? Share Your Idea
Tags: webdev, javascript, programming, tutorial
Published: 2023-08-30 02:13:09

If you ask, **[is the first McDonald's still open](https://openread.net/is-the-first-mcdonalds-still-open/)**? Not, it is not open. But why? let's find. The first McDonald's restaurant was opened by brothers Maurice (“Mac”) and Richard McDonald in San Bernardino, California in 1940, is not open anymore. It is now a museum called The Original McDonald's Museum.
The oldest McDonald's restaurant that is still open is located at 10207 Lakewood Boulevard at Florence Avenue in Downey, California. 

It was the third McDonald's restaurant and opened on August 18, 1953. It was also the second restaurant franchised by Richard and Maurice McDonald, before the involvement of Ray Kroc in the company. There are a few other early McDonald's restaurants that are still standing, but they are not in operation.

•The seventh McDonald's, at 1057 East Mission Boulevard in Pomona, California, which is now a doughnut shop.

•A restaurant built in 1962 at 2434 Almaden Road in San Jose, California, which is the only other remaining early McDonald's still in operation in California, although a modern restaurant is now attached to it.

•A single-arch McDonald's sign at 2801 S. Western Avenue in Los Angeles, California.

So, the answer to your question is no, the first McDonald's is not still open. However, there are a few other early McDonald's restaurants that are still standing, and one of them is still in operation.

## Oldest McDonald’s Restaurant 

The oldest McDonald's restaurant that is still open is located at 10207 Lakewood Boulevard at Florence Avenue in Downey, California. It was the third McDonald's restaurant and opened on August 18, 1953. It was also the second restaurant franchised by Richard and Maurice McDonald, before the involvement of Ray Kroc in the company.

The restaurant is a single-story, red and white building with a small parking lot. It has a classic McDonald's sign with two arches, which was the original design for the company's restaurants.

The interior of the restaurant is also a bit of a time capsule. It has the original booths and tables, as well as the original cash registers. The menu is also the same as it was in the 1950s, with items like hamburgers, cheeseburgers, fries, and milkshakes.

The restaurant is a popular tourist destination, and it is often featured in movies and television shows. It is a reminder of the early days of McDonald's, when the company was just starting out and was still experimenting with its formula.
Rental Mobil Bogor
Published: 2023-08-30 02:07:21

Kami adalah penyedia jasa [Rental Mobil Bogor](https://fizhtravel.com/rental-mobil/bogor/) yang akan mempermudah mobilitas / perjalanan anda dengan di fasilitasi armada yang bersih,terawat, dan menjamin kenyamanan berkendara anda seperti menggunakan kendaraan pribadi anda sendiri yang tidak dapat anda  temukan di tempat lain. Dengan kami rental mobil bogor fizhtravel menjadi mudah dan menyenangkan.
Understanding Ownership in Rust: Ensuring Safety and Preventing Errors
Tags: rust, programming, softwareengineering, performance
Published: 2023-08-30 01:56:48

Rust is a programming language renowned for its safety and performance. One of the core features that enables this safety is the ownership system. In this article, we will delve into the concept of ownership in Rust and how it helps prevent common memory-related programming errors, such as memory leaks and invalid data access.

**What is Ownership?**

In Rust, every value has a variable that is its "owner," and this variable is responsible for deallocating the memory associated with the value when it's no longer needed. This concept is known as "ownership." Ownership is one of the three main rules in Rust's memory management system, with the other two being "borrowing" and "lifetimes," which work together to ensure program safety.

**Basic Ownership Rules**

Every value in Rust has exactly one variable that owns it. This means that when the variable goes out of scope, the value is automatically deallocated.

When a variable is assigned to another variable, the value is moved. This means the original variable can no longer be used to access the value unless an explicit copy is made.

You can use the cloning operation to create complete copies of values in Rust. This creates a new variable that owns an independent copy of the value.

These simple yet powerful rules help prevent many common memory-related programming errors like memory leaks and race conditions.

**Advantages of Ownership in Rust**

The ownership system in Rust offers several advantages:

**Prevents Memory Leaks:** Since Rust tracks the ownership of values, it can automatically free memory when values are no longer needed, eliminating memory leaks.

**Prevents Invalid Access:** The ownership system ensures you can't access values after they've been deallocated, preventing hard-to-trace bugs.

**Avoids Race Conditions:** Rust guarantees that you don't share mutable data between threads without proper synchronization, preventing race conditions.

**Optimizes Performance:** The ownership system allows the Rust compiler to make memory and code optimizations, resulting in more efficient programs.

**Conclusion**

Ownership is a fundamental feature of the Rust programming language that significantly contributes to its safety and performance. With a robust memory management system and clear rules for value ownership, Rust enables developers to write safer and more reliable code, eliminating memory leaks and memory-related errors. By understanding and correctly applying ownership concepts, programmers can harness Rust's full potential for secure and efficient software development.
What is your favorite programming language and why?
Tags: webdev, programming, discuss, softwaredevelopment
Published: 2023-08-30 01:46:46

There are so many languages out there that enable us to create so many new things. So, I got curious what languages others may find to be the best tool for the job.

I'll start. I enjoy using JavaScript the most due to its versatility and what it allows front-end devs to produce. Let me know in the comments what you think!
Here's 30 fun cybersecurity search engines:
Published: 2023-08-30 00:42:35



1. DeHashed—View leaked credentials.
2. SecurityTrails—Extensive DNS data.
3. DorkSearch—Really fast Google dorking.
4. ExploitDB—Archive of various exploits.
5. ZoomEye—Gather information about targets.
6. Pulsedive—Search for threat intelligence.
7. GrayHatWarfare—Search public S3 buckets.
8. PolySwarm—Scan files and URLs for threats.
9. Fofa—Search for various threat intelligence.
10. LeakIX—Search publicly indexed information.
11. DNSDumpster—Search for DNS records quickly.
12. FullHunt—Search and discovery attack surfaces.
13. AlienVault—Extensive threat intelligence feed.
14. ONYPHE—Collects cyber-threat intelligence data.
15. Grep App—Search across a half million git repos.
16. URL Scan—Free service to scan and analyse websites.
17. Vulners—Search vulnerabilities in a large database.
18. WayBackMachine—View content from deleted websites.
19. Shodan—Search for devices connected to the internet.
20. Netlas—Search and monitor internet connected assets.
21. CRT sh—Search for certs that have been logged by CT.
22. Wigle—Database of wireless networks, with statistics.
23. PublicWWW—Marketing and affiliate marketing research.
24. Binary Edge—Scans the internet for threat intelligence.
25. GreyNoise—Search for devices connected to the internet.
26. Hunter—Search for email addresses belonging to a website.
27. Censys—Assessing attack surface for internet connected devices.
28. IntelligenceX—Search Tor, I2P, data leaks, domains, and emails.
29. Packet Storm Security—Browse latest vulnerabilities and exploits.
30. SearchCode—Search 75 billion lines of code from 40 million projects.

Add up more on comment !!!!
Unleashing Web Development Power with Flask: A Beginner's Guide
Tags: webdev, beginners, programming, flask
Published: 2023-08-30 00:31:51

Whether you're new to coding or a seasoned developer looking to explore Flask, this guide will walk you through the fundamentals of Flask and provide you with practical code snippets to kickstart your web development journey.

**Understanding Flask**

Flask is a lightweight yet powerful web framework that empowers developers to build web applications efficiently. Following the "micro" philosophy, Flask equips you with essential tools to start, while also allowing the freedom to integrate additional components as needed.

**Setting Up Flask**

To get started, ensure you have Python installed, and then install Flask using the following command:

```bash
pip install Flask
```

**Creating Your First Flask App**

Begin by creating a new Python file, let's name it `app.py`, and let's build a basic Flask app:

```python
from flask import Flask

app = Flask(__name__)

@app.route('/')
def hello_world():
    return 'Hello, Flask!'
```

Run your app using:

```bash
python app.py
```

Open your browser and navigate to `http://localhost:5000` to see your "Hello, Flask!" message.

**Dynamic Routing**

One of Flask's strengths is dynamic routing, allowing you to generate URLs that adapt based on user input. Here's an example:

```python
@app.route('/user/<username>')
def show_user_profile(username):
    return f'Hello, {username}!'
```

**Handling Forms**

Flask simplifies form handling too. Below is a snippet demonstrating basic form handling:

```python
from flask import Flask, request

app = Flask(__name__)

@app.route('/login', methods=['GET', 'POST'])
def login():
    if request.method == 'POST':
        username = request.form['username']
        password = request.form['password']
        # Implement login logic here
    else:
        return 'Login Page'
```


Flask's simplicity and versatility make it an excellent choice for both novices and experienced developers in the world of web development. From building your first app to dealing with dynamic routes and managing form submissions, this guide provides a glimpse into Flask's potential.

Remember, this is just the beginning of your journey with Flask. As you dive deeper, you'll uncover more advanced features and techniques. So, harness Flask's capabilities and embark on your web development adventure with confidence!

Stay tuned for further in-depth Flask tutorials and discover the limitless possibilities that this micro web framework offers. Happy coding!
부끄럽지 않게 살자
Published: 2023-08-29 23:58:56

우리 가족과, 함께 일했던 동료들에게, 이 사회에 부끄럽지 않게 살고 싶다.
그 동안 가족을 핑계로 나 자신의 원칙, 내가 중요하게 생각하는 가치를 양보해 오거나 타협한 점들이 없지 않았다. 

꽤 수 년동안 오래 그래왔지만, 이제 더 이상은 어려울 것 같다. 나의 선택을 존중해 주는 가족과 동료들이 있기에 더더욱 내가 핑계댈 곳은 이제 없다. 

사랑하는 나의 두 딸에게 부끄럽지 않고 당당하게 살아달라고 부탁하며 지원할 계획인데, 나 자신이 그렇게 살고 있지 못하다면 이는 아리스토텔레스 수사학 3요소 중 에토스를 지키지 못한 꼴이 된다. 

삶의 선택들은, 생각보다 인생 전체를 결정짓는 큰 요소가 아니라고 생각한다. 오히려 선택한 후, 어떤 자세와 노력으로 해당 결정에 책임지느냐의 문제이지.
CodeWars Blog #1
Tags: codenewbie, womenintech, programming
Published: 2023-08-29 23:53:56


The problem: 

**In this simple assignment you are given a number and have to make it negative. But maybe the number is already negative?**

This problem is asking for a program that will take a number and return the same number as a negative. If the number already entered is negative, then it negates the program. 

To counteract that issue, Math.abs() method will first take the number and convert it to its absolute form (if it's negative, it will return positive) then multiply by (-1).  


The Solution: 
```
function makeNegative(num){
  return Math.abs(num) * -1
}
```
Don't get attached
Tags: webdev, programming, softwareengineering
Published: 2023-08-29 23:44:04

One of the situations you will encounter in the professional world of web development is that things won't always go your way. There will be times when you gave it your all and maybe 110% with element of rush because of a tight deadline to finish a task, and then you hear your project manager saying, we're descoping the project and focus on another one. 

Your heart sinks. 

But as someone who has been doing this for more than 8 years, I have developed an attitude towards code that this may not be used. Your code which you have worked on can be deprioritized, postponed or worse, may never be used.

So useful tip, don't get attached. Just think of the learnings you have gained through it, document it as much as possible, and try to move on. 

Your code unpublished doesn't mean you're not a good developer. The experience you get from it matters the most.