Create a bare bones server using nodejs core modules and not expressjs.
- http
- url
| const fs = require("fs"); | |
| const path = "./temp.txt"; | |
| const errorCallback = (err) => { | |
| console.log(err); | |
| console.log("Failed writing to the files"); | |
| } | |
| const doneCallback2 = (err) => { | |
| if(err) { |
| <html> | |
| <head> | |
| <style> | |
| .body { | |
| background-color: green; | |
| } | |
| .source_container { | |
| position: relative; | |
| padding: 20px 20px; | |
| background-color: red; |
| /** | |
| * This is a modified form of issue https://github.com/caolan/async/issues/1611 with title | |
| * "waterfall Callback was already called. #1611" | |
| * | |
| * Reason: | |
| * First, the line no 16 executes causing the next waterfall step to execute. | |
| * Subsequently line no 25 causes an exception which is gaurded by Promise.then in the first step | |
| * which in turn causes catch block in line no 21 to be executed. | |
| */ |
| /** | |
| * Write a program to encode a given number in roman numeral form | |
| // I - 1 | |
| // V - 5 | |
| // X - 10 | |
| // L - 50 | |
| // C - 100 | |
| // D - 500 | |
| // M - 1000 | |
| * @param {*} number |
| # Online Python compiler (interpreter) to run Python online. | |
| # Write Python 3 code in this online editor and run it. | |
| students = [ | |
| {"name": "user1", "marks": 10, "gender": "male"}, | |
| {"name": "user2", "marks": 12, "gender": "male"}, | |
| {"name": "user3", "marks": 15, "gender": "male"}, | |
| {"name": "user4", "marks": 20, "gender": "female"}, | |
| {"name": "user5", "marks": 25, "gender": "female"}] | |
| print("1: print all student names") |
| //Rentrant function. - Software terminology | |
| //generator functions. - javascript terminology () | |
| //Read more here https://codeburst.io/understanding-generators-in-es6-javascript-with-examples-6728834016d5 | |
| function wait() { | |
| return new Promise(resolve => setTimeout(resolve, 3000)); | |
| } | |
| async function sayAwaitHello() { | |
| await wait(); |
| /** | |
| * A simple promise generator that waits for n seconds and returns a promise that resolves to n. | |
| */ | |
| function wait(n) { | |
| return new Promise(resolve => setTimeout(resolve.bind(null, n), n * 1000)); | |
| } | |
| /** | |
| * A simple function that invokes promise and displays the result. | |
| */ |
| [ | |
| {"name": "user1", "marks": 10, "gender": "male"}, | |
| {"name": "user2", "marks": 12, "gender": "male"}, | |
| {"name": "user3", "marks": 15, "gender": "male"}, | |
| {"name": "user4", "marks": 20, "gender": "female"}, | |
| {"name": "user5", "marks": 25, "gender": "female"}, | |
| ] | |
| Expected output : |
| import React, {Component} from 'react'; | |
| import { | |
| Text, | |
| View, | |
| Animated, | |
| StyleSheet, | |
| SafeAreaView, | |
| FlatList, | |
| LayoutChangeEvent, | |
| } from 'react-native'; |