JustPaste.it

KVM INSTALLATION

 

egrep -c '(vmx|svm)' /proc/cpuinfo 

check if output > 2 else no installation   

 

sudo apt update

sudo apt install qemu-kvm libvirt-daemon-system libvirt-clients bridge-utils

 

sudo adduser ‘username of the system  we can use whoami to know’ libvirt 

sudo adduser ‘username of the system  we can use whoami to know’ kvm

 

 

sudo systemctl enable --now libvirtd

sudo apt install virt-manager

sudo virt-manager

 

#do through GUI form here

_______________________________________________________________________________________________________________________

 

OpenStack 

add the iso

login id and password openstack

sudo dhclient enp0s3 

sudo ifconfig enp0s3 up

 localhost:8888

login web

id :- admin

password :- openstack

_______________________________________________________________________________________________________________________

 

 

REST

crud

 

npm init -y

create index.js

npm I express

node index.js

 

const express = require('express');
const bodyParser = require('body-parser');

const app = express();
const PORT = 3000;

// Dummy data to simulate a database
let books = [
    { id: 1, title: "Book 1", author: "Author 1" },
    { id: 2, title: "Book 2", author: "Author 2" },
    { id: 3, title: "Book 3", author: "Author 3" }
];

app.use(bodyParser.json());

// Endpoint to get all books
app.get('/books', (req, res) => {
    res.json(books);
});

// Endpoint to get a single book by id
app.get('/books/:id', (req, res) => {
    const id = parseInt(req.params.id);
    const book = books.find(book => book.id === id);
    if (book) {
        res.json(book);
    } else {
        res.status(404).json({ error: 'Book not found' });
    }
});

// Endpoint to create a new book
app.post('/books', (req, res) => {
    const data = req.body;
    const newBook = { id: books.length + 1, ...data };
    books.push(newBook);
    res.status(201).json(newBook);
});

// Endpoint to update an existing book
app.put('/books/:id', (req, res) => {
    const id = parseInt(req.params.id);
    const data = req.body;
    const index = books.findIndex(book => book.id === id);
    if (index !== -1) {
        books[index] = { ...books[index], ...data };
        res.json(books[index]);
    } else {
        res.status(404).json({ error: 'Book not found' });
    }
});

// Endpoint to delete a book
app.delete('/books/:id', (req, res) => {
    const id = parseInt(req.params.id);
    const index = books.findIndex(book => book.id === id);
    if (index !== -1) {
        books.splice(index, 1);
        res.sendStatus(204);
    } else {
        res.status(404).json({ error: 'Book not found' });
    }
});

app.listen(PORT, () => {
    console.log(`Server is running on port ${PORT}`);
});
_______________________________________________________________________________________________________________________

MTOM

 

using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading.Tasks;
using System.Web;
using System.Web.Hosting;
using System.Web.Http;
using System.Web.Mvc;

namespace DownloadImageAPI.Controllers
{
    public class FileController : ApiController
    {
        private readonly string DefaultImage = HostingEnvironment.MapPath("~/Content/default.png");

        public HttpResponseMessage Get()
        {
            Image baseImage = Image.FromFile(DefaultImage);

            using (var memoryImage = new MemoryStream())
            {
                baseImage.Save(memoryImage, ImageFormat.Png);

                byte[] imgData = memoryImage.ToArray();
                MemoryStream ms = new MemoryStream(imgData);
                HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.OK);
                response.Content = new StreamContent(ms);
                response.Content.Headers.ContentType = new
                System.Net.Http.Headers.MediaTypeHeaderValue("image/png");
                return response;

            }

        }
    }

}