OneCompiler

waruziko ntazakundwa by irap 1k

Example heading with h2 size

// React Frontend (Upload and Track Views)
import { useState, useEffect } from 'react';
import { db, storage } from './firebase'; // Firebase config
import { collection, addDoc, updateDoc, doc, increment, getDoc } from 'firebase/firestore';
import { ref, uploadBytes, getDownloadURL } from 'firebase/storage';

function MusicUploader() {
const [file, setFile] = useState(null);
const [songs, setSongs] = useState([]);

const handleUpload = async () => {
if (!file) return;
const storageRef = ref(storage, songs/${file.name});
await uploadBytes(storageRef, file);
const url = await getDownloadURL(storageRef);
await addDoc(collection(db, 'songs'), { url, views: 0 });
};

const handlePlay = async (id) => {
const songRef = doc(db, 'songs', id);
await updateDoc(songRef, { views: increment(1) });
};

return (
<div>
<input type="file" onChange={(e) => setFile(e.target.files[0])} />
<button onClick={handleUpload}>Upload</button>
{songs.map((song) => (
<div key={song.id}>
<audio src={song.url} controls onPlay={() => handlePlay(song.id)} />
</div>
))}
</div>
);
}

export default MusicUploader;

// Backend: Node.js Express (Pay Per View)
const express = require('express');
const cors = require('cors');
const { db } = require('./firebaseAdmin'); // Firebase Admin SDK
const { getDoc, doc } = require('firebase/firestore');
const paypal = require('@paypal/checkout-server-sdk');

const app = express();
app.use(cors());
app.use(express.json());

app.post('/pay-irap1k', async (req, res) => {
const songId = req.body.songId;
const songRef = doc(db, 'songs', songId);
const song = await getDoc(songRef);
if (!song.exists()) return res.status(404).send('Song not found');
const views = song.data().views;
const amountToPay = views * 0.01; // Example: $0.01 per view

// PayPal payment logic here...

res.json({ message: IRAP 1K will receive $${amountToPay} });
});

app.listen(5000, () => console.log('Server running on port 5000'));

Example heading with h3 size

Following is sample java code.

int i = 10;
if(i>0){
    System.out.println('positive');
}

waruziko-ntazakundwa-=-irap 1k.mp3