Skip to content

Instantly share code, notes, and snippets.

var builder = WebApplication.CreateBuilder(args);
var app = builder.Build();
app.MapPost("/upload/{filename}", async (HttpRequest request, string filename, IWebHostEnvironment env) =>
{
if (!request.ContentType?.StartsWith("image/") == true)
return Results.BadRequest();
var uploads = Path.Combine(env.WebRootPath ?? env.ContentRootPath, "uploads");
if (!Directory.Exists(uploads))
namespace DZ3
{
public class Program
{
public static void Main(string[] args)
{
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddControllers();
var app = builder.Build();
function createOrder(orderId) {
return new Promise((resolve, reject) => {
setTimeout(() => {
const success = true;
console.log(`order created: ${orderId}`);
if (success) resolve(orderId);
else reject("Error creating order");
}, 1000);
});
function divide(a, b, onSuccess, onError) {
if(b === 0) {
return onError(new Error("Divide by zero is restricted."));
}
else {
return onSuccess(a / b);
}
}
const input = document.querySelector("input");
input.addEventListener("keydown", function (event) {
if(event.key >= "0" && event.key <= "9") {
event.preventDefault();
}
});
//----------------------------------------------------------------------- 111
// const target = document.querySelector(".insert-here");
//
// const table = document.createElement("table");
//
// const rows = 3;
// const cells = 3;
//
// for (let i = 0; i < rows; i++) {
class Product {
constructor(id, name, price, description) {
this.id = id;
this.name = name;
this.price = price;
this.description = description;
}
}
class ProductCatalog {
class Printmachine {
constructor(size, color, fontFamily) {
this.fontSize = size;
this.color = color;
this.fontFamily = fontFamily;
}
print(string) {
const element = document.createElement("div");
//------------------------------------------------ Class
class Point {
constructor(x, y) {
this.x = x;
this.y = y;
}
}
class Rectangle {
constructor(a, b) {
//----------------------------------------111 1
const comparaison = (a, b) => {
if (a < b) return -1;
if (a > b) return 1;
return 0;
}
//-----------------------------------------222 3
const stringSum = (...numbers) => numbers.reduce((a, x) => a + x, 0).toString();