teleren/devto huggingface dataset:
image upload
Published: 2023-10-29 07:54:16

# Creating a RESTful API with Flask: GET and POST Methods

In this article, we'll explore how to create a RESTful API using the Flask web framework in Python. We'll focus on two essential HTTP methods: GET and POST.

## Prerequisites

Before you start, make sure you have the following installed:

- Python: You'll need Python installed on your system.
- Flask: You can install Flask using `pip install Flask`.

## Setting Up Your Flask Application

Start by creating a new directory for your project and a Python file (e.g., `app.py`) to hold your Flask application.

```
# Import the Flask module
from flask import Flask, request, jsonify

# Create a Flask app
app = Flask(__name__)

# Dummy data for demonstration
data = []

# Define a route for the root URL
@app.route('/')
def hello_world():
    return "Hello, World!"

# GET Method
@app.route('/api/data', methods=['GET'])
def get_data():
    return jsonify(data)

# POST Method
@app.route('/api/data', methods=['POST'])
def add_data():
    new_item = request.json  # Get JSON data from the request body
    data.append(new_item)   # Append data to the list
    return jsonify({"message": "Data added successfully!"})

if __name__ == '__main__':
    app.run(debug=True) 
   ```
html logo
Published: 2023-10-29 07:49:54

# Creating a RESTful API with Flask: GET and POST Methods

In this article, we'll explore how to create a RESTful API using the Flask web framework in Python. We'll focus on two essential HTTP methods: GET and POST.

## Prerequisites

Before you start, make sure you have the following installed:

- Python: You'll need Python installed on your system.
- Flask: You can install Flask using `pip install Flask`.

## Setting Up Your Flask Application

Start by creating a new directory for your project and a Python file (e.g., `app.py`) to hold your Flask application.

```
# Import the Flask module
from flask import Flask, request, jsonify

# Create a Flask app
app = Flask(__name__)

# Dummy data for demonstration
data = []

# Define a route for the root URL
@app.route('/')
def hello_world():
    return "Hello, World!"

# GET Method
@app.route('/api/data', methods=['GET'])
def get_data():
    return jsonify(data)

# POST Method
@app.route('/api/data', methods=['POST'])
def add_data():
    new_item = request.json  # Get JSON data from the request body
    data.append(new_item)   # Append data to the list
    return jsonify({"message": "Data added successfully!"})

if __name__ == '__main__':
    app.run(debug=True) 
   ```
Insecure Deserialization
Published: 2023-10-29 07:46:30

Hey there! Let's talk about one of the top 10 OWASP vulnerabilities called Insecure Deserialization. It's a fancy term that refers to a vulnerability where a server tries to unpack data provided by a user, but that data actually contains hidden malicious code. Sneaky, right? This vulnerability can occur in various programming languages like Python, Java, PHP, Ruby, and more.

Before diving deeper in to the vulnerability itself, lets try to grasp what serialization is.

**What is Serialization and Deserialization?**

Serialization can be defined as the process of converting complex data structures and objects into a stream of bytes. This is necessary because this is a transportable format of the data and can then be stored into a file, database or memory for later use. When an object is serialized, ideally its state is preserved, meaning, the object’s attributes along with their values remains unchanged

Obviously, then deserialization refers to the opposite, that is, the converting a stream of bytes from a file, database or memory into a complex data structure or object which is human readable.

**What is Insecure Deserialization?**

An insecure deserialization also known as object injection, as previously mentioned, is a  vulnerability that occurs when a server tries to unpack the data provided by a user which triggers the execution of malicious code which was hidden into this data. This could leak out sensitive information or even provide with remote code execution which could be devastating for a company.

**So if insecure deserialization is so dangerous how can you protect yourself?**

Insecure deserialization can indeed be quite dangerous, but there are ways to protect yourself. One important step is to never pass a serialized object manipulated by an untrusted user to the deserialize function. This prevents potential manipulation of the object and direct execution of malicious code. Instead, consider using a secure and lightweight data-interchange format like JSON. 

Additionally, If you do have to accept serialized objects, here are some tips to mitigate insecure deserialization:

- Implement digital signatures and other integrity checks to prevent malicious object creation or data interference.
- Run deserialization code in low privilege environments.
- Keep a log of deserialization exceptions and failures.
- Monitor and restrict all incoming and outgoing network activity from deserialization containers and servers.
- Utilize deserialization methods like JSON, XML, and YAML that are language-agnostic.

Alright, folks! That's a wrap on our little chat about Insecure Deserialization. Remember, this vulnerability is like a sneaky ninja hiding malicious code in innocent-looking data. 

{% embed https://www.youtube.com/watch?v=jwzeJU_62IQ %}

Check out the above video on Insecure Deserialization by [PwnFunction ](https://www.youtube.com/c/PwnFunction)where he digs deeper into how an actual attack is carried out.

Until next time. Happy Hacking!
flask logo
Published: 2023-10-29 07:40:54

# Creating a RESTful API with Flask: GET and POST Methods

In this article, we'll explore how to create a RESTful API using the Flask web framework in Python. We'll focus on two essential HTTP methods: GET and POST.

## Prerequisites

Before you start, make sure you have the following installed:

- Python: You'll need Python installed on your system.
- Flask: You can install Flask using `pip install Flask`.

## Setting Up Your Flask Application

Start by creating a new directory for your project and a Python file (e.g., `app.py`) to hold your Flask application.

```
# Import the Flask module
from flask import Flask, request, jsonify

# Create a Flask app
app = Flask(__name__)

# Dummy data for demonstration
data = []

# Define a route for the root URL
@app.route('/')
def hello_world():
    return "Hello, World!"

# GET Method
@app.route('/api/data', methods=['GET'])
def get_data():
    return jsonify(data)

# POST Method
@app.route('/api/data', methods=['POST'])
def add_data():
    new_item = request.json  # Get JSON data from the request body
    data.append(new_item)   # Append data to the list
    return jsonify({"message": "Data added successfully!"})

if __name__ == '__main__':
    app.run(debug=True) 
   ```
kubernetes
Published: 2023-10-29 07:36:16

Kubernetes is an open-source system for automating deployment, scaling, and management of containerized applications.

It groups containers that make up an application into logical units for easy management and discovery.
It is designed to be portable, extensible, and self-healing.

Kubernetes is widely used in the industry to manage containerized applications.

How it works:

Kubernetes is a container orchestration platform that automates the deployment and scaling of containerized workloads. It is designed to be portable, extensible, and self-healing.

Kubernetes works by grouping containers that make up an application into logical units for easy management and discovery. It provides a platform for developers to deploy and manage their applications in a scalable and efficient manner.

Kubernetes uses declarative configuration to define the desired state of the application. The user specifies the desired state of the application in a YAML file, which is then used by Kubernetes to create and manage the application.

Kubernetes also provides self-healing capabilities. If a container fails, Kubernetes will automatically restart it. If a node fails, Kubernetes will reschedule the containers running on that node to other healthy nodes in the cluster

kubernetes cluster:

A Kubernetes cluster is a set of node machines for running containerized applications. At a minimum, a cluster contains a control plane and one or more compute machines, or nodes.

The control plane is responsible for maintaining the desired state of the cluster, such as which applications are running and which container images they use.

an example of how to deploy an application using Kubernetes:

Create a deployment YAML file that describes the desired state of your application. Here is an example YAML file for a simple web application:
apiVersion: apps/v1
kind: Deployment
metadata:
 name: my-web-app
spec:
 replicas: 3
 selector:
  matchLabels:
   app: my-web-app
 template:
  metadata:
   labels:
    app: my-web-app
  spec:
   containers:
   - name: my-web-app
    image: my-web-app:v1
    ports:
    - containerPort: 80

This YAML file specifies that we want to deploy three replicas of a web application called my-web-app. The application runs in a container with the image my-web-app:v1 and listens on port 80.

Use the kubectl apply command to create the deployment:
kubectl apply -f deployment.yaml

This command creates the deployment and starts the specified number of replicas.

Verify that the deployment was created successfully:
kubectl get deployments

This command should output information about the my-web-app deployment.

Expose the deployment as a service:
kubectl expose deployment my-web-app --type=LoadBalancer --port=80 --target-port=80

This command creates a service that exposes the my-web-app deployment on port 80.

Verify that the service was created successfully:
kubectl get services

This command should output information about the my-web-app service.
Weekly Dev Findings 11
Tags: webdev, javascript, news, python
Published: 2023-10-29 07:31:21

## Python

- [ruff-formatter](https://astral.sh/blog/the-ruff-formatter) - ruff linter now formats code just like black formatter
- [benedict](https://github.com/fabiocaccamo/python-benedict) - Python dict with super powers
- [Panther](https://github.com/AliRn76/Panther) - yet another async web framework with optional [ODM](https://pypi.org/project/pantherdb/)
- [Spring Python](https://docs.spring.io/spring-python/1.2.x/sphinx/html/overview.html) - Java Spring framework features
  like IOC in Python
- [Polars](https://www.pola.rs/) - pandas alternative with better API and duckdb compat
- [queryish](https://github.com/wagtail/queryish) - Django ORM for JSON endpoints
- [ptpython-shell](https://realpython.com/ptpython-shell/) - article about better Python REPL
- [pycln](https://github.com/hadialqattan/pycln) - tool for automatically removing unused imports

## JS

- https://mswjs.io/ - JS request mocking lib

## AI

- https://star-history.com/blog/coding-ai - review of open source ai code completion tools
- [cody](https://about.sourcegraph.com/cody) - reads project source, but understands context on high level, no deep
  context
- [refact.ai](https://github.com/smallcloudai/refact) - yet another ai codding assistant

## Other

- [openapi-devtools](https://github.com/AndrewWalsh/openapi-devtools) - chrome extension that turns any website underhood requests into swagger
- [system-design-101](https://github.com/ByteByteGoHq/system-design-101) - system design interview prep
- [penpot](https://github.com/penpot/penpot) - open source figma alternative
- https://medium.com/@addyosmani/photoshop-is-now-on-the-web-38d70954365a?s=09 - article about Photoshop in browser
Laravel - Telescope
Tags: laravel, php, debug, telescope
Published: 2023-10-29 07:27:13

Effective debugging is crucial as your project grows in complexity. It not only aids in identifying and resolving issues but also contributes to system optimization. Debugging can be performed manually by inspecting the entire codebase, or by utilizing powerful tools designed for this purpose.

In the world of Laravel development, one such indispensable tool is Laravel Telescope. This incredible package provides real-time insights into your application's performance and various events. Whether you're a seasoned Laravel developer or just starting your journey with this framework, understanding how to leverage Telescope can significantly enhance your development workflow.

Laravel Telescope not only simplifies the debugging process but also gives you deep visibility into your application's inner workings. You can track HTTP requests, database queries, and even log entries, all in real-time. With the comprehensive set of tools and intuitive interface, troubleshooting issues becomes a breeze, allowing you to focus on building exceptional features for your Laravel project.

If you're eager to dive into Laravel debugging with Telescope, you're in luck. We've created a dedicated branch in our [Laravel Hands-On repository](https://github.com/mazimez/laravel-hands-on/tree/debugging-telescope), where you'll find hands-on examples, code samples, and step-by-step guides. This branch is designed to help you master Telescope's capabilities and become a more efficient Laravel developer.
Project Stage 1
Tags: spo600
Published: 2023-10-28 21:48:49

**Procedure**
**1.Obtain the source code for the current development version of GCC from the Git repository.**
`git clone git://gcc.gnu.org/git/gcc.git`
`cd gcc`

**2.Build the source code to produce a working compiler on each of two environments.**

- To build GCC outside of the source tree to keep things clean, `build` directory was created as following.

`mkdir build`

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/k6vb8u1fphhgqr6ztf6e.png)

`cd build`

**3.Configure the build for each of two environments. It sets up the build to create a compiler.**

x86_64 system
`../configure --target=x86_64-linux-gnu --enable-languages=c,c++
`

AArch64 system
`../configure --target=aarch64-linux-gnu --enable-languages=c,c++`

**4.Build GCC.**
Run `make` to start the compilation process.

**The time taken to perform the build**
It took about 2 hours for build to happen.

**Impact of `-jN` options to perform the build**
The `-jN` option in the `make` command allows `make` to execute up to N jobs in parallel.
For example, if I run: `make -j4`, this allows make to run up to 4 jobs simultaneously, resulting in a much faster build process. 
I used this command for AArch64 architecture, and it was a lot faster.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2vwgjphkg6aw0iwztl46.png)

**How I have proven that I have a working compiler**
- Checked gcc version: `gcc --version`
- Create a new test program named `hello.c` as following. 
```shell
#include <stdio.h>

int main() {
    printf("Hello, World!\n");
    return 0;
}
```
- Compile the program: `gcc -o hello hello.c`
- Run the program: `./hello`
![run the program in portugal](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/d5crrv0gj9oic6zobzjn.png)

![run the program in israel](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4v0f0sk3gssau991lgyh.png)

--> This verifies that I have successfully built and installed a working compiler.
Breeze y Jetstream en Español
Tags: laravel, tailwindcss, livewire, jetstream
Published: 2023-10-29 07:17:41

**<--- Pasos para traducir los textos de la librería Jetstream y Breeze en Laravel 10--->**

Después de haber instalado cualquiera de las dos paqueterías antes mencionadas, debemos instalar la paquetería Lang, esta nos ayudará a seleccionar el idioma para trabajar con estos paquetes de inicio.

1. Vamos a requerir la paquetería Lang, para ello debemos ejecutar en nuestro proyecto el siguiente comando:

**composer require laravel-lang/lang --dev**

2. Instalamos los idiomas de la paquetería Lang:

**composer require laravel-lang/publisher laravel-lang/lang laravel-lang/attributes --dev**

3. elegir el idioma a ejecutar:

**php artisan lang:add es**

4. Después de haber ejecutado los comandos anteriores, se debe hacer una configuración en la ruta config/app.php de tu proyecto Laravel, se debe modificar la parte de 'locale' => 'en' a:

**'locale' => 'es'**

Con estos pasos la configuración al idioma Español queda lista.
Upmark- Digital Marketing Institute
Published: 2023-10-29 07:16:55

Upmark, define our role as a [digital marketing institute in Ahmedabad](https://upmark.in/digital-marketing-training-course-in-ahmedabad/). The lasting demand for digital marketing increases the opportunities for everyone. We develop skills that match with industry requirement. In the segments of digital marketing, we position ourselves as the fastest growing brand for digital marketing courses. Upmark is an innovative & dedicated school of digital advertisements in Ahmedabad, India. We learn from our experiences and make them deliverable to the aspirants by developing curriculum and content that match with the industry’s benchmarks. We also develop innovative approaches to deliver the content of digital marketing in the best adaptable mode so that learning digital marketing becomes easy. Learn Everything About SEO With 100% Placement Assistance. You Can Opt For Offline Training. Enroll for Our Classroom SEO Course in Ahmedabad, or Online Live Practical Training on Digital Platforms.
Have You Ever Encountered A Ghost in the Machine? 👻
Tags: discuss, watercooler
Published: 2023-10-29 07:00:00

Ever felt like you've crossed paths with "Ghosts in the Machine"? Whether it's mysterious tech phenomena or real-world ghostly encounters, we want to hear your tales. What unexplained events have you witnessed, and how do you perceive the supernatural in our tech-infused lives? Join the conversation and share your stories! 👻📡

---

👻🎃 Join Our Halloween Costume Contest! 🎃👻

Embrace the eerie season, don your most creative costume, and snap a pic. Share it with our community for a chance to win badges. [Check out our post for more info](https://dev.to/devteam/coding-in-costume-join-our-halloween-costume-contest-3dg1). 😈📸🏆

Follow the DEVteam for more discussions and online camaraderie!

{% embed [https://dev.to/devteam](https://dev.to/devteam) %}
Create Custom Artisan Command in Laravel
Published: 2023-10-29 06:56:50

Sometimes we need to create custom commands to fast-forward our tasks. So here is the process to create your custom command for your Laravel project.

First Create a command class with this command -

```
php artisan make:command CustomCommand
```
After that, it will create a file on this path - 

> app\Console\Commands\CustomCommand.php

Then Update your custom command like this - 

```
protected $signature = 'make:files {name}';
```
Add your command description and update your custom conditions on handle() method.

Here is added my conditions - 

```
public function handle()
    {
        $name = $this->argument('name');

        $this->call('make:model', [
            'name' => $name,
            '-m' => true,
        ]);

        $this->call('make:controller', [
            'name' => "{$name}Controller",
        ]);

        $this->call('make:request', [
            'name' => "{$name}/{$name}StoreRequest",
        ]);

        $this->call('make:request', [
            'name' => "{$name}/{$name}UpdateRequest",
        ]);

        $this->info("Resource files for {$name} have been generated.");

        return Command::SUCCESS;
    }
```

Done You have successfully created your command for your project.
Placeholder Contributor
Tags: hack23contributor
Published: 2023-10-29 06:55:39

<!-- ✨This template is only meant to get your ideas going, so please feel free to write your own title, structure, and words! ✨ -->

### Intro
<!-- Share a bit about yourself as a contributor. Is this your first Hacktoberfest, or have you contributed to others? Feel free to embed your GitHub account by using {% embed LINK %} -->

### Highs and Lows
<!-- What were some of your biggest accomplishments or light-bulb moments this month? Did any problems come up that seemed impossible to fix? How did you adapt in those cases?  -->

### Growth
<!-- What was your skillset before Hacktoberfest 2023 and how did it improve? Have your learning or career goals changed since working on these new projects? -->
React -CSV-Reader
Tags: javascript
Published: 2023-10-29 06:42:44

follow: https://www.npmjs.com/package/react-csv-reader


``` js
import React from "react";
import ReactDOM from "react-dom";
import CSVReader from "react-csv-reader";
import "./styles.css";

const handleForce = (data, fileInfo) => console.log(data, fileInfo);

const papaparseOptions = {
  header: true,
  dynamicTyping: true,
  skipEmptyLines: true,
  transformHeader: (header) => header.toLowerCase().replace(/\W/g, "_")
};

const reader = (
  <div className="container">
    <CSVReader
      cssClass="csv-reader-input"
      label="Select CSV with secret Death Star statistics"
      onFileLoaded={handleForce}
      onError={() => {
        console.log("error");
      }}
      parserOptions={papaparseOptions}
      inputId="ObiWan"
      inputName="ObiWan"
      inputStyle={{ color: "red" }}
    />
    <p>and then open the console</p>
  </div>
);

ReactDOM.render(reader, document.getElementById("root"));

```
HacktoberFest Contributor
Tags: hack23contributor, hacktoberfest, hacktoberfest23
Published: 2023-10-29 06:41:34

**Hacktoberfest made October month too special**

Hey DEVs, I'm Prasad, Happy to share I have completed my 3rd year of hacktoberfest challenge. 

[GitHub Profile](https://github.com/prasadpoojary)

### Highs and Lows
I have decided to take an opportunity to contribute with different technologies. Initially it took time, but later on it was quite smooth and challenging. I was highly excited on the outcome. Difficulties are invalid PR acceptance by the maintainer. I have seen lots of repos where I couldn't even run the application because of missing classes or methods. I had to contribute on new feature and also the existing bug. 

### Growth
Hacktoberfest is a great way of encouraging developers. I just needed some push from others to do something and here is the hacktoberfest for that. Initially I was little busy, I started late but when I started contributing it was not restrict to 4 PRs, I just continued to contribute on multiple repo's irrespective of challenges. It helped a lot in understanding others code and way of practicing clean code.
GeoPuzzle - arrange the pieces of the world
Tags: hack23maintainer
Published: 2023-10-29 06:29:01

### Intro
I'm developing pet-project [GeoPuzzle](https://geopuzzle.org) over 8 years. Here, in the form of a game, you can learn the names as well as locations of each country or a state while having fun doing it. To begin the game, select a region from the map or the list and look at its flag, coat of arms and perhaps, even more information to help you learn geography. after Registration, you can create your puzzles from more than 100,000 regions!

### Project
I have an open source repo on [github](https://github.com/TyVik/geopuzzle). Feel free to contribute and suggest new ideas.

### Highs and Lows
I live in Russia, so due to political reason I have not possibilities to use a valid key for google maps. Also, I have other restrictions by Patreon, Hetzner, etc... So, I'm going to switch to my own infrastructure: Leaflet with OSM, some hosting in Russia.

### Growth
This repository is a good example how to work with OSM and Wikidata via SPARQL. Also, I have some integrations for education purpose.