How to use fs.readFile method in Appium

Best JavaScript code snippet using appium

main.js

Source:main.js Github

copy

Full Screen

...16 // Pass to next layer of middleware17 next();18});19app.get('/PM10/2014', function (req, res , next) {20 fs.readFile( __dirname + "/" + "data/PM10/pm102014.json", 'utf8', function (err, data) {21 22 res.end( data );23 });24});25app.get('/PM10/2013', function (req, res , next) {26 fs.readFile( __dirname + "/" + "data/PM10/pm102013.json", 'utf8', function (err, data) {27 28 res.end( data );29 });30});31app.get('/PM10/2012', function (req, res , next) {32 fs.readFile( __dirname + "/" + "data/PM10/pm102012.json", 'utf8', function (err, data) {33 34 res.end( data );35 });36});37app.get('/PM10/2011', function (req, res , next) {38 fs.readFile( __dirname + "/" + "data/PM10/pm102011.json", 'utf8', function (err, data) {39 40 res.end( data );41 });42});43app.get('/PM10/2010', function (req, res , next) {44 fs.readFile( __dirname + "/" + "data/PM10/pm102010.json", 'utf8', function (err, data) {45 46 res.end( data );47 });48});49app.get('/PM10/2009', function (req, res , next) {50 fs.readFile( __dirname + "/" + "data/PM10/pm102009.json", 'utf8', function (err, data) {51 52 res.end( data );53 });54});55app.get('/PM10/2008', function (req, res , next) {56 fs.readFile( __dirname + "/" + "data/PM10/pm102008.json", 'utf8', function (err, data) {57 58 res.end( data );59 });60});61app.get('/PM10/2007', function (req, res , next) {62 fs.readFile( __dirname + "/" + "data/PM10/pm102007.json", 'utf8', function (err, data) {63 64 res.end( data );65 });66});67app.get('/PM10/2006', function (req, res , next) {68 fs.readFile( __dirname + "/" + "data/PM10/pm102006.json", 'utf8', function (err, data) {69 70 res.end( data );71 });72});73app.get('/PM10/2005', function (req, res , next) {74 fs.readFile( __dirname + "/" + "data/PM10/pm102005.json", 'utf8', function (err, data) {75 76 res.end( data );77 });78});79app.get('/PM10/2004', function (req, res , next) {80 fs.readFile( __dirname + "/" + "data/PM10/pm102004.json", 'utf8', function (err, data) {81 82 res.end( data );83 });84});85app.get('/PM10/2003', function (req, res , next) {86 fs.readFile( __dirname + "/" + "data/PM10/pm102003.json", 'utf8', function (err, data) {87 88 res.end( data );89 });90});91app.get('/PM10/2002', function (req, res , next) {92 fs.readFile( __dirname + "/" + "data/PM10/pm102002.json", 'utf8', function (err, data) {93 94 res.end( data );95 });96});97app.get('/PM10/2001', function (req, res , next) {98 fs.readFile( __dirname + "/" + "data/PM10/pm102001.json", 'utf8', function (err, data) {99 100 res.end( data );101 });102});103app.get('/PM10/2000', function (req, res , next) {104 fs.readFile( __dirname + "/" + "data/PM10/pm102000.json", 'utf8', function (err, data) {105 106 res.end( data );107 });108});109app.get('/PM10/1999', function (req, res , next) {110 fs.readFile( __dirname + "/" + "data/PM10/pm101999.json", 'utf8', function (err, data) {111 112 res.end( data );113 });114});115app.get('/PM2_5/2014', function (req, res , next) {116 fs.readFile( __dirname + "/" + "data/PM25/pm252014.json", 'utf8', function (err, data) {117 118 res.end( data );119 });120});121app.get('/PM2_5/2013', function (req, res , next) {122 fs.readFile( __dirname + "/" + "data/PM25/pm252013.json", 'utf8', function (err, data) {123 124 res.end( data );125 });126});127app.get('/PM2_5/2012', function (req, res , next) {128 fs.readFile( __dirname + "/" + "data/PM25/pm252012.json", 'utf8', function (err, data) {129 130 res.end( data );131 });132});133app.get('/PM2_5/2011', function (req, res , next) {134 fs.readFile( __dirname + "/" + "data/PM25/pm252011.json", 'utf8', function (err, data) {135 136 res.end( data );137 });138});139app.get('/PM2_5/2010', function (req, res , next) {140 fs.readFile( __dirname + "/" + "data/PM25/pm252010.json", 'utf8', function (err, data) {141 142 res.end( data );143 });144});145app.get('/PM2_5/2009', function (req, res , next) {146 fs.readFile( __dirname + "/" + "data/PM25/pm252009.json", 'utf8', function (err, data) {147 148 res.end( data );149 });150});151app.get('/PM2_5/2008', function (req, res , next) {152 fs.readFile( __dirname + "/" + "data/PM25/pm252008.json", 'utf8', function (err, data) {153 154 res.end( data );155 });156});157app.get('/PM2_5/2007', function (req, res , next) {158 fs.readFile( __dirname + "/" + "data/PM25/pm252007.json", 'utf8', function (err, data) {159 160 res.end( data );161 });162});163app.get('/PM2_5/2006', function (req, res , next) {164 fs.readFile( __dirname + "/" + "data/PM25/pm252006.json", 'utf8', function (err, data) {165 166 res.end( data );167 });168});169app.get('/PM2_5/2005', function (req, res , next) {170 fs.readFile( __dirname + "/" + "data/PM25/pm252005.json", 'utf8', function (err, data) {171 172 res.end( data );173 });174});175app.get('/PM2_5/2004', function (req, res , next) {176 fs.readFile( __dirname + "/" + "data/PM25/pm252004.json", 'utf8', function (err, data) {177 178 res.end( data );179 });180});181app.get('/PM2_5/2003', function (req, res , next) {182 fs.readFile( __dirname + "/" + "data/PM25/pm252003.json", 'utf8', function (err, data) {183 184 res.end( data );185 });186});187app.get('/PM2_5/2002', function (req, res , next) {188 fs.readFile( __dirname + "/" + "data/PM25/pm252002.json", 'utf8', function (err, data) {189 190 res.end( data );191 });192});193app.get('/PM2_5/2001', function (req, res , next) {194 fs.readFile( __dirname + "/" + "data/PM25/pm252001.json", 'utf8', function (err, data) {195 196 res.end( data );197 });198});199app.get('/PM2_5/2000', function (req, res , next) {200 fs.readFile( __dirname + "/" + "data/PM25/pm252000.json", 'utf8', function (err, data) {201 202 res.end( data );203 });204});205app.get('/PM25/1999', function (req, res , next) {206 fs.readFile( __dirname + "/" + "data/PM25/pm251999.json", 'utf8', function (err, data) {207 208 res.end( data );209 });210});211app.get('/NH3/2014', function (req, res , next) {212 fs.readFile( __dirname + "/" + "data/NH3/NH32014.json", 'utf8', function (err, data) {213 214 res.end( data );215 });216});217app.get('/NH3/2013', function (req, res , next) {218 fs.readFile( __dirname + "/" + "data/NH3/NH32013.json", 'utf8', function (err, data) {219 220 res.end( data );221 });222});223app.get('/NH3/2012', function (req, res , next) {224 fs.readFile( __dirname + "/" + "data/NH3/NH32012.json", 'utf8', function (err, data) {225 226 res.end( data );227 });228});229app.get('/NH3/2011', function (req, res , next) {230 fs.readFile( __dirname + "/" + "data/PNH3/NH32011.json", 'utf8', function (err, data) {231 232 res.end( data );233 });234});235app.get('/NH3/2010', function (req, res , next) {236 fs.readFile( __dirname + "/" + "data/NH3/NH32010.json", 'utf8', function (err, data) {237 238 res.end( data );239 });240});241app.get('/NH3/2009', function (req, res , next) {242 fs.readFile( __dirname + "/" + "data/NH3/NH32009.json", 'utf8', function (err, data) {243 244 res.end( data );245 });246});247app.get('/NH3/2008', function (req, res , next) {248 fs.readFile( __dirname + "/" + "data/NH3/NH32008.json", 'utf8', function (err, data) {249 250 res.end( data );251 });252});253app.get('/NH3/2007', function (req, res , next) {254 fs.readFile( __dirname + "/" + "data/NH3/NH32007.json", 'utf8', function (err, data) {255 256 res.end( data );257 });258});259app.get('/NH3/2006', function (req, res , next) {260 fs.readFile( __dirname + "/" + "data/NH3/NH32006.json", 'utf8', function (err, data) {261 262 res.end( data );263 });264});265app.get('/NH3/2005', function (req, res , next) {266 fs.readFile( __dirname + "/" + "data/NH3/NH32005.json", 'utf8', function (err, data) {267 268 res.end( data );269 });270});271app.get('/NH3/2004', function (req, res , next) {272 fs.readFile( __dirname + "/" + "data/NH3/NH32004.json", 'utf8', function (err, data) {273 274 res.end( data );275 });276});277app.get('/NH3/2003', function (req, res , next) {278 fs.readFile( __dirname + "/" + "data/NH3/NH32003.json", 'utf8', function (err, data) {279 280 res.end( data );281 });282});283app.get('/NH3/2002', function (req, res , next) {284 fs.readFile( __dirname + "/" + "data/NH3/NH32002.json", 'utf8', function (err, data) {285 286 res.end( data );287 });288});289app.get('/NH3/2001', function (req, res , next) {290 fs.readFile( __dirname + "/" + "data/NH3/NH32001.json", 'utf8', function (err, data) {291 292 res.end( data );293 });294});295app.get('/NH3/2000', function (req, res , next) {296 fs.readFile( __dirname + "/" + "data/NH3/NH32000.json", 'utf8', function (err, data) {297 298 res.end( data );299 });300});301app.get('/NH3/1999', function (req, res , next) {302 fs.readFile( __dirname + "/" + "data/NH3/NH31999.json", 'utf8', function (err, data) {303 304 res.end( data );305 });306});307app.get('/NMVOC/2014', function (req, res , next) {308 fs.readFile( __dirname + "/" + "data/NMVOC/NMVOC2014.json", 'utf8', function (err, data) {309 310 res.end( data );311 });312});313app.get('/NMVOC/2013', function (req, res , next) {314 fs.readFile( __dirname + "/" + "data/NMVOC/NMVOC2013.json", 'utf8', function (err, data) {315 316 res.end( data );317 });318});319app.get('/NMVOC/2012', function (req, res , next) {320 fs.readFile( __dirname + "/" + "data/NMVOC/NMVOC2012.json", 'utf8', function (err, data) {321 322 res.end( data );323 });324});325app.get('/NMVOC/2011', function (req, res , next) {326 fs.readFile( __dirname + "/" + "data/NMVOC/NMVOC2011.json", 'utf8', function (err, data) {327 328 res.end( data );329 });330});331app.get('/NMVOC/2010', function (req, res , next) {332 fs.readFile( __dirname + "/" + "data/NMVOC/NMVOC2010.json", 'utf8', function (err, data) {333 334 res.end( data );335 });336});337app.get('/NMVOC/2009', function (req, res , next) {338 fs.readFile( __dirname + "/" + "data/NMVOC/NMVOC2009.json", 'utf8', function (err, data) {339 340 res.end( data );341 });342});343app.get('/NMVOC/2008', function (req, res , next) {344 fs.readFile( __dirname + "/" + "data/NMVOC/NMVOC2008.json", 'utf8', function (err, data) {345 346 res.end( data );347 });348});349app.get('/NMVOC/2007', function (req, res , next) {350 fs.readFile( __dirname + "/" + "data/NMVOC/NMVOC2007.json", 'utf8', function (err, data) {351 352 res.end( data );353 });354});355app.get('/NMVOC/2006', function (req, res , next) {356 fs.readFile( __dirname + "/" + "data/NMVOC/NMVOC2006.json", 'utf8', function (err, data) {357 358 res.end( data );359 });360});361app.get('/NMVOC/2005', function (req, res , next) {362 fs.readFile( __dirname + "/" + "data/NMVOC/NMVOC2005.json", 'utf8', function (err, data) {363 364 res.end( data );365 });366});367app.get('/NMVOC/2004', function (req, res , next) {368 fs.readFile( __dirname + "/" + "data/NMVOC/NMVOC2004.json", 'utf8', function (err, data) {369 370 res.end( data );371 });372});373app.get('/NMVOC/2003', function (req, res , next) {374 fs.readFile( __dirname + "/" + "data/NMVOC/NMVOC2003.json", 'utf8', function (err, data) {375 376 res.end( data );377 });378});379app.get('/NMVOC/2002', function (req, res , next) {380 fs.readFile( __dirname + "/" + "data/NMVOC/NMVOC2002.json", 'utf8', function (err, data) {381 382 res.end( data );383 });384});385app.get('/NMVOC/2001', function (req, res , next) {386 fs.readFile( __dirname + "/" + "data/NMVOC/NMVOC2001.json", 'utf8', function (err, data) {387 388 res.end( data );389 });390});391app.get('/NMVOC/2000', function (req, res , next) {392 fs.readFile( __dirname + "/" + "data/NMVOC/NMVOC2000.json", 'utf8', function (err, data) {393 394 res.end( data );395 });396});397app.get('/NMVOC/1999', function (req, res , next) {398 fs.readFile( __dirname + "/" + "data/NMVOC/NMVOC1999.json", 'utf8', function (err, data) {399 400 res.end( data );401 });402});403app.get('/NOX/2014', function (req, res , next) {404 fs.readFile( __dirname + "/" + "data/NOX/NOX2014.json", 'utf8', function (err, data) {405 406 res.end( data );407 });408});409app.get('/NOX/2013', function (req, res , next) {410 fs.readFile( __dirname + "/" + "data/NOX/NOX2013.json", 'utf8', function (err, data) {411 412 res.end( data );413 });414});415app.get('/NOX/2012', function (req, res , next) {416 fs.readFile( __dirname + "/" + "data/NOX/NOX2012.json", 'utf8', function (err, data) {417 418 res.end( data );419 });420});421app.get('/NOX/2011', function (req, res , next) {422 fs.readFile( __dirname + "/" + "data/NOX/NOX2011.json", 'utf8', function (err, data) {423 424 res.end( data );425 });426});427app.get('/NOX/2010', function (req, res , next) {428 fs.readFile( __dirname + "/" + "data/NOX/NOX2010.json", 'utf8', function (err, data) {429 430 res.end( data );431 });432});433app.get('/NOX/2009', function (req, res , next) {434 fs.readFile( __dirname + "/" + "data/NOX/NOX2009.json", 'utf8', function (err, data) {435 436 res.end( data );437 });438});439app.get('/NOX/2008', function (req, res , next) {440 fs.readFile( __dirname + "/" + "data/NOX/NOX2008.json", 'utf8', function (err, data) {441 442 res.end( data );443 });444});445app.get('/NOX/2007', function (req, res , next) {446 fs.readFile( __dirname + "/" + "data/NOX/NOX2007.json", 'utf8', function (err, data) {447 448 res.end( data );449 });450});451app.get('/NOX/2006', function (req, res , next) {452 fs.readFile( __dirname + "/" + "data/NOX/NOX2006.json", 'utf8', function (err, data) {453 454 res.end( data );455 });456});457app.get('/NOX/2005', function (req, res , next) {458 fs.readFile( __dirname + "/" + "data/NOX/NOX2005.json", 'utf8', function (err, data) {459 460 res.end( data );461 });462});463app.get('/NOX/2004', function (req, res , next) {464 fs.readFile( __dirname + "/" + "data/NOX/NOX2004.json", 'utf8', function (err, data) {465 466 res.end( data );467 });468});469app.get('/NOX/2003', function (req, res , next) {470 fs.readFile( __dirname + "/" + "data/NOX/NOX2003.json", 'utf8', function (err, data) {471 472 res.end( data );473 });474});475app.get('/NOX/2002', function (req, res , next) {476 fs.readFile( __dirname + "/" + "data/NOX/NOX2002.json", 'utf8', function (err, data) {477 478 res.end( data );479 });480});481app.get('/NOX/2001', function (req, res , next) {482 fs.readFile( __dirname + "/" + "data/NOX/NOX2001.json", 'utf8', function (err, data) {483 484 res.end( data );485 });486});487app.get('/NOX/2000', function (req, res , next) {488 fs.readFile( __dirname + "/" + "data/NOX/NOX2000.json", 'utf8', function (err, data) {489 490 res.end( data );491 });492});493app.get('/NOX/1999', function (req, res , next) {494 fs.readFile( __dirname + "/" + "data/NOX/NOX1999.json", 'utf8', function (err, data) {495 496 res.end( data );497 });498});499app.get('/SOX/2014', function (req, res , next) {500 fs.readFile( __dirname + "/" + "data/SOX/SOX2014.json", 'utf8', function (err, data) {501 502 res.end( data );503 });504});505app.get('/SOX/2013', function (req, res , next) {506 fs.readFile( __dirname + "/" + "data/SOX/SOX2013.json", 'utf8', function (err, data) {507 508 res.end( data );509 });510});511app.get('/SOX/2012', function (req, res , next) {512 fs.readFile( __dirname + "/" + "data/SOX/SOX2012.json", 'utf8', function (err, data) {513 514 res.end( data );515 });516});517app.get('/SOX/2011', function (req, res , next) {518 fs.readFile( __dirname + "/" + "data/SOX/SOX2011.json", 'utf8', function (err, data) {519 520 res.end( data );521 });522});523app.get('/SOX/2010', function (req, res , next) {524 fs.readFile( __dirname + "/" + "data/SOX/SOX2010.json", 'utf8', function (err, data) {525 526 res.end( data );527 });528});529app.get('/SOX/2009', function (req, res , next) {530 fs.readFile( __dirname + "/" + "data/SOX/SOX2009.json", 'utf8', function (err, data) {531 532 res.end( data );533 });534});535app.get('/SOX/2008', function (req, res , next) {536 fs.readFile( __dirname + "/" + "data/SOX/SOX2008.json", 'utf8', function (err, data) {537 538 res.end( data );539 });540});541app.get('/SOX/2007', function (req, res , next) {542 fs.readFile( __dirname + "/" + "data/SOX/SOX2007.json", 'utf8', function (err, data) {543 544 res.end( data );545 });546});547app.get('/SOX/2006', function (req, res , next) {548 fs.readFile( __dirname + "/" + "data/SOX/SOX2006.json", 'utf8', function (err, data) {549 550 res.end( data );551 });552});553app.get('/SOX/2005', function (req, res , next) {554 fs.readFile( __dirname + "/" + "data/SOX/SOX2005.json", 'utf8', function (err, data) {555 556 res.end( data );557 });558});559app.get('/SOX/2004', function (req, res , next) {560 fs.readFile( __dirname + "/" + "data/SOX/SOX2004.json", 'utf8', function (err, data) {561 562 res.end( data );563 });564});565app.get('/SOX/2003', function (req, res , next) {566 fs.readFile( __dirname + "/" + "data/SOX/SOX2003.json", 'utf8', function (err, data) {567 568 res.end( data );569 });570});571app.get('/SOX/2002', function (req, res , next) {572 fs.readFile( __dirname + "/" + "data/SOX/SOX2002.json", 'utf8', function (err, data) {573 574 res.end( data );575 });576});577app.get('/SOX/2001', function (req, res , next) {578 fs.readFile( __dirname + "/" + "data/SOX/SOX2001.json", 'utf8', function (err, data) {579 580 res.end( data );581 });582});583app.get('/SOX/2000', function (req, res , next) {584 fs.readFile( __dirname + "/" + "data/SOX/SOX2000.json", 'utf8', function (err, data) {585 586 res.end( data );587 });588});589app.get('/SOX/1999', function (req, res , next) {590 fs.readFile( __dirname + "/" + "data/SOX/SOX1999.json", 'utf8', function (err, data) {591 592 res.end( data );593 });594});595app.get('/country/UK', function (req, res , next) {596 fs.readFile( __dirname + "/" + "data/Countries/UK.json", 'utf8', function (err, data) {597 598 res.end( data );599 });600});601app.get('/country/AT', function (req, res , next) {602 fs.readFile( __dirname + "/" + "data/Countries/AT.json", 'utf8', function (err, data) {603 604 res.end( data );605 });606});607app.get('/country/BE', function (req, res , next) {608 fs.readFile( __dirname + "/" + "data/Countries/BE.json", 'utf8', function (err, data) {609 610 res.end( data );611 });612});app.get('/country/BG', function (req, res , next) {613 fs.readFile( __dirname + "/" + "data/Countries/BG.json", 'utf8', function (err, data) {614 615 res.end( data );616 });617});app.get('/country/CH', function (req, res , next) {618 fs.readFile( __dirname + "/" + "data/Countries/CH.json", 'utf8', function (err, data) {619 620 res.end( data );621 });622});app.get('/country/CY', function (req, res , next) {623 fs.readFile( __dirname + "/" + "data/Countries/CY.json", 'utf8', function (err, data) {624 625 res.end( data );626 });627});app.get('/country/CZ', function (req, res , next) {628 fs.readFile( __dirname + "/" + "data/Countries/CZ.json", 'utf8', function (err, data) {629 630 res.end( data );631 });632});app.get('/country/DE', function (req, res , next) {633 fs.readFile( __dirname + "/" + "data/Countries/DE.json", 'utf8', function (err, data) {634 635 res.end( data );636 });637});app.get('/country/DK', function (req, res , next) {638 fs.readFile( __dirname + "/" + "data/Countries/DK.json", 'utf8', function (err, data) {639 640 res.end( data );641 });642});app.get('/country/EE', function (req, res , next) {643 fs.readFile( __dirname + "/" + "data/Countries/EE.json", 'utf8', function (err, data) {644 645 res.end( data );646 });647});app.get('/country/ES', function (req, res , next) {648 fs.readFile( __dirname + "/" + "data/Countries/ES.json", 'utf8', function (err, data) {649 650 res.end( data );651 });652});app.get('/country/FI', function (req, res , next) {653 fs.readFile( __dirname + "/" + "data/Countries/FI.json", 'utf8', function (err, data) {654 655 res.end( data );656 });657});app.get('/country/FR', function (req, res , next) {658 fs.readFile( __dirname + "/" + "data/Countries/FR.json", 'utf8', function (err, data) {659 660 res.end( data );661 });662});app.get('/country/HR', function (req, res , next) {663 fs.readFile( __dirname + "/" + "data/Countries/HR.json", 'utf8', function (err, data) {664 665 res.end( data );666 });667});app.get('/country/HU', function (req, res , next) {668 fs.readFile( __dirname + "/" + "data/Countries/HU.json", 'utf8', function (err, data) {669 670 res.end( data );671 });672});app.get('/country/IE', function (req, res , next) {673 fs.readFile( __dirname + "/" + "data/Countries/IE.json", 'utf8', function (err, data) {674 675 res.end( data );676 });677});app.get('/country/IT', function (req, res , next) {678 fs.readFile( __dirname + "/" + "data/Countries/IT.json", 'utf8', function (err, data) {679 680 res.end( data );681 });682});app.get('/country/LI', function (req, res , next) {683 fs.readFile( __dirname + "/" + "data/Countries/LI.json", 'utf8', function (err, data) {684 685 res.end( data );686 });687});app.get('/country/LT', function (req, res , next) {688 fs.readFile( __dirname + "/" + "data/Countries/LT.json", 'utf8', function (err, data) {689 690 res.end( data );691 });692});app.get('/country/LU', function (req, res , next) {693 fs.readFile( __dirname + "/" + "data/Countries/LU.json", 'utf8', function (err, data) {694 695 res.end( data );696 });697});app.get('/country/LV', function (req, res , next) {698 fs.readFile( __dirname + "/" + "data/Countries/LV.json", 'utf8', function (err, data) {699 700 res.end( data );701 });702});app.get('/country/NL', function (req, res , next) {703 fs.readFile( __dirname + "/" + "data/Countries/NL.json", 'utf8', function (err, data) {704 705 res.end( data );706 });707});app.get('/country/NO', function (req, res , next) {708 fs.readFile( __dirname + "/" + "data/Countries/NO.json", 'utf8', function (err, data) {709 710 res.end( data );711 });712});app.get('/country/PL', function (req, res , next) {713 fs.readFile( __dirname + "/" + "data/Countries/PL.json", 'utf8', function (err, data) {714 715 res.end( data );716 });717});app.get('/country/PT', function (req, res , next) {718 fs.readFile( __dirname + "/" + "data/Countries/PT.json", 'utf8', function (err, data) {719 720 res.end( data );721 });722});app.get('/country/RO', function (req, res , next) {723 fs.readFile( __dirname + "/" + "data/Countries/RO.json", 'utf8', function (err, data) {724 725 res.end( data );726 });727});app.get('/country/SE', function (req, res , next) {728 fs.readFile( __dirname + "/" + "data/Countries/SE.json", 'utf8', function (err, data) {729 730 res.end( data );731 });732});app.get('/country/SI', function (req, res , next) {733 fs.readFile( __dirname + "/" + "data/Countries/SI.json", 'utf8', function (err, data) {734 735 res.end( data );736 });737});app.get('/country/SK', function (req, res , next) {738 fs.readFile( __dirname + "/" + "data/Countries/SK.json", 'utf8', function (err, data) {739 740 res.end( data );741 });742});app.get('/raw/PM10', function (req, res , next) {743 fs.readFile( __dirname + "/" + "data/rawdata/PM10.json", 'utf8', function (err, data) {744 745 res.end( data );746 });747});app.get('/raw/PM2_5', function (req, res , next) {748 fs.readFile( __dirname + "/" + "data/rawdata/PM2_5.json", 'utf8', function (err, data) {749 750 res.end( data );751 });752});app.get('/raw/NH3', function (req, res , next) {753 fs.readFile( __dirname + "/" + "data/rawdata/NH3.json", 'utf8', function (err, data) {754 755 res.end( data );756 });757});app.get('/raw/NMVOC', function (req, res , next) {758 fs.readFile( __dirname + "/" + "data/rawdata/NMVOC.json", 'utf8', function (err, data) {759 760 res.end( data );761 });762});app.get('/raw/NOX', function (req, res , next) {763 fs.readFile( __dirname + "/" + "data/rawdata/NOX.json", 'utf8', function (err, data) {764 765 res.end( data );766 });767});app.get('/raw/SOX', function (req, res , next) {768 fs.readFile( __dirname + "/" + "data/rawdata/SOX.json", 'utf8', function (err, data) {769 770 res.end( data );771 });772});773app.get('/rawdata/UK', function (req, res , next) {774 fs.readFile( __dirname + "/" + "data/rawdata/Countries/UK.json", 'utf8', function (err, data) {775 776 res.end( data );777 });778});779app.get('/rawdata/AT', function (req, res , next) {780 fs.readFile( __dirname + "/" + "data/rawdata/Countries/AT.json", 'utf8', function (err, data) {781 782 res.end( data );783 });784});785app.get('/rawdata/BE', function (req, res , next) {786 fs.readFile( __dirname + "/" + "data/rawdata/Countries/BE.json", 'utf8', function (err, data) {787 788 res.end( data );789 });790});app.get('/rawdata/BG', function (req, res , next) {791 fs.readFile( __dirname + "/" + "data/rawdata/Countries/BG.json", 'utf8', function (err, data) {792 793 res.end( data );794 });795});app.get('/rawdata/CH', function (req, res , next) {796 fs.readFile( __dirname + "/" + "data/rawdata/Countries/CH.json", 'utf8', function (err, data) {797 798 res.end( data );799 });800});app.get('/rawdata/CY', function (req, res , next) {801 fs.readFile( __dirname + "/" + "data/rawdata/Countries/CY.json", 'utf8', function (err, data) {802 803 res.end( data );804 });805});app.get('/rawdata/CZ', function (req, res , next) {806 fs.readFile( __dirname + "/" + "data/rawdata/Countries/CZ.json", 'utf8', function (err, data) {807 808 res.end( data );809 });810});app.get('/rawdata/DE', function (req, res , next) {811 fs.readFile( __dirname + "/" + "data/rawdata/Countries/DE.json", 'utf8', function (err, data) {812 813 res.end( data );814 });815});app.get('/rawdata/DK', function (req, res , next) {816 fs.readFile( __dirname + "/" + "data/rawdata/Countries/DK.json", 'utf8', function (err, data) {817 818 res.end( data );819 });820});app.get('/rawdata/EE', function (req, res , next) {821 fs.readFile( __dirname + "/" + "data/rawdata/Countries/EE.json", 'utf8', function (err, data) {822 823 res.end( data );824 });825});app.get('/rawdata/ES', function (req, res , next) {826 fs.readFile( __dirname + "/" + "data/rawdata/Countries/ES.json", 'utf8', function (err, data) {827 828 res.end( data );829 });830});app.get('/rawdata/FI', function (req, res , next) {831 fs.readFile( __dirname + "/" + "data/rawdata/Countries/FI.json", 'utf8', function (err, data) {832 833 res.end( data );834 });835});app.get('/rawdata/FR', function (req, res , next) {836 fs.readFile( __dirname + "/" + "data/rawdata/Countries/FR.json", 'utf8', function (err, data) {837 838 res.end( data );839 });840});app.get('/rawdata/HR', function (req, res , next) {841 fs.readFile( __dirname + "/" + "data/rawdata/Countries/HR.json", 'utf8', function (err, data) {842 843 res.end( data );844 });845});app.get('/rawdata/HU', function (req, res , next) {846 fs.readFile( __dirname + "/" + "data/rawdata/Countries/HU.json", 'utf8', function (err, data) {847 848 res.end( data );849 });850});app.get('/rawdata/IE', function (req, res , next) {851 fs.readFile( __dirname + "/" + "data/rawdata/Countries/IE.json", 'utf8', function (err, data) {852 853 res.end( data );854 });855});app.get('/rawdata/IT', function (req, res , next) {856 fs.readFile( __dirname + "/" + "data/rawdata/Countries/IT.json", 'utf8', function (err, data) {857 858 res.end( data );859 });860});app.get('/rawdata/LI', function (req, res , next) {861 fs.readFile( __dirname + "/" + "data/rawdata/Countries/LI.json", 'utf8', function (err, data) {862 863 res.end( data );864 });865});app.get('/rawdata/LT', function (req, res , next) {866 fs.readFile( __dirname + "/" + "data/rawdata/Countries/LT.json", 'utf8', function (err, data) {867 868 res.end( data );869 });870});app.get('/rawdata/LU', function (req, res , next) {871 fs.readFile( __dirname + "/" + "data/rawdata/Countries/LU.json", 'utf8', function (err, data) {872 873 res.end( data );874 });875});app.get('/rawdata/LV', function (req, res , next) {876 fs.readFile( __dirname + "/" + "data/rawdata/Countries/LV.json", 'utf8', function (err, data) {877 878 res.end( data );879 });880});app.get('/rawdata/NL', function (req, res , next) {881 fs.readFile( __dirname + "/" + "data/rawdata/Countries/NL.json", 'utf8', function (err, data) {882 883 res.end( data );884 });885});app.get('/rawdata/NO', function (req, res , next) {886 fs.readFile( __dirname + "/" + "data/rawdata/Countries/NO.json", 'utf8', function (err, data) {887 888 res.end( data );889 });890});app.get('/rawdata/PL', function (req, res , next) {891 fs.readFile( __dirname + "/" + "data/rawdata/Countries/PL.json", 'utf8', function (err, data) {892 893 res.end( data );894 });895});app.get('/rawdata/PT', function (req, res , next) {896 fs.readFile( __dirname + "/" + "data/rawdata/Countries/PT.json", 'utf8', function (err, data) {897 898 res.end( data );899 });900});app.get('/rawdata/RO', function (req, res , next) {901 fs.readFile( __dirname + "/" + "data/rawdata/Countries/RO.json", 'utf8', function (err, data) {902 903 res.end( data );904 });905});app.get('/rawdata/SE', function (req, res , next) {906 fs.readFile( __dirname + "/" + "data/rawdata/Countries/SE.json", 'utf8', function (err, data) {907 908 res.end( data );909 });910});app.get('/rawdata/SI', function (req, res , next) {911 fs.readFile( __dirname + "/" + "data/rawdata/Countries/SI.json", 'utf8', function (err, data) {912 913 res.end( data );914 });915});app.get('/rawdata/SK', function (req, res , next) {916 fs.readFile( __dirname + "/" + "data/rawdata/Countries/SK.json", 'utf8', function (err, data) {917 918 res.end( data );919 });920 });921var server = app.listen(8081, function () {922 var host = server.address().address;923 var port = server.address().port;924 console.log("Example app listening at http://%s:%s", host, port);...

Full Screen

Full Screen

callbacks.js

Source:callbacks.js Github

copy

Full Screen

...31 console.log(content);32}33function printFileAsync(name) {34 const fs = require("fs");35 fs.readFile(`./6/data/${name}`, { encoding: "UTF8" }, function(err, content) {36 console.log(name, "is ready:");37 console.log(content);38 });39}40// Sync:41console.log("Reading file sync 1.json");42printFileSync("1.json");43console.log("Reading file sync 2.json");44printFileSync("2.json");45console.log("Done executing sync commands");46// Async47console.log("Reading file async 1.json");48printFileAsync("1.json");49console.log("Reading file async 2.json");50printFileAsync("2.json");51console.log("Done scheduling async commands");52// You can think of Async code like 'schedule to execute this operation in background'53// Lets see how fs.readFile looks like:54fs.readFile(55 // relative path to file56 `./data/1.json`,57 // reading options58 undefined, 59 // special function called callback:60 function(err, myfilecontent) {61 console.log(myfilecontent);62 }63);64// Callback is a special function that will be executed once your async operation is complete65// You can think of it like -66// please call this function once file will be opened and content will be loaded67// Notice! fs.readFile DOES NOT RETURN ANYTHING (undefined)68let a = fs.readFile();69a; // undefined70// Result of your async function will be passed to callback function71fs.readFile(72 // relative path to file73 `./6/data/notexisting.json`,74 // reading options75 { encoding: "UTF8" },76 // special function called callback:77 function(err, content) {78 console.log("Here is our async function returned result!");79 console.log(content);80 }81);82// ERRORS handling:83fs.readFile(84 // relative path to file85 `./data/notexisting.json`,86 // reading options87 { encoding: "UTF8" },88 // special function called callback:89 function(err, content) {90 // It is convention - first parameter of callback function must be err91 // if we have error92 if (err) {93 console.log("Oh no, we have error!");94 console.log(err);95 // you can re-throw if you want96 throw err;97 }98 console.log(name, "is ready:");99 console.log(content);100 }101);102// Why we can't just do try/catch?103try {104 fs.readFile();105} catch (err) {106 // blabla107}108// Because async function is only SCHEDULED at this point, and not actually executed109// Execution stack will be different when function will be actually executed,110// so try/catch cannot handle that111// Why callbacks are bad?112// When you need to run commands in exact order113// Example: Reading first file, using content of that file to read next files114// DO NOT WORRY IF YOU DONT UNDERSTAND115// This is called pyramid of DOOM116const fs = require("fs");117fs.readFile(118 // path to first file119 `./data/paths.json`,120 // options121 { encoding: "UTF8" },122 // callback123 function(err, filepaths) {124 // converting string to json125 let parsedFilepaths = JSON.parse(filepaths);126 // showing what we got127 console.log("Got file paths!", parsedFilepaths);128 fs.readFile(parsedFilepaths.first, { encoding: "UTF8" }, function(129 err,130 contentFirst131 ) {132 console.log("Got first file", contentFirst);133 fs.readFile(parsedFilepaths.second, { encoding: "UTF8" }, function(134 err,135 contentSecond136 ) {137 console.log("Got second file", contentSecond);138 fs.readFile(parsedFilepaths.three, { encoding: "UTF8" }, function(139 err,140 contentThird141 ) {142 // OOOPS - undefined!143 console.log("Got third file", contentThird);144 });145 });146 });147 }148);149// Problem #2 - Error handling150// Who can say where the problem is?151const fs = require("fs");152fs.readFile(153 // path to first file154 `./6/data/paths.json`,155 // options156 { encoding: "UTF8" },157 // callback158 function(err, filepaths) {159 // converting string to json160 let parsedFilepaths = JSON.parse(filepaths);161 // showing what we got162 console.log("Got file paths!", parsedFilepaths);163 fs.readFile(parsedFilepaths.first, { encoding: "UTF8" }, function(164 err,165 contentFirst166 ) {167 console.log("Got first file", contentFirst);168 fs.readFile(parsedFilepaths.second, { encoding: "UTF8" }, function(169 err,170 contentSecond171 ) {172 console.log("Got second file", contentSecond);173 fs.readFile(174 `./${parsedFilepaths.three}`,175 { encoding: "UTF8" },176 function(err, contentThird) {177 // OOOPS - undefined!178 console.log("Got third file", contentThird);179 }180 );181 });182 });183 }184);185// Problem is here186// fs.readFile(`./${parsedFilepaths.three}`, - wrong string187const fs = require("fs");188fs.readFile(189 // path to first file190 `./6/data/paths.json`,191 // options192 { encoding: "UTF8" },193 // callback194 function(err, filepaths) {195 if (err) {196 throw err;197 }198 // converting string to json199 let parsedFilepaths;200 try {201 parsedFilepaths = JSON.parse(filepaths);202 } catch (err) {203 throw err;204 }205 // showing what we got206 console.log("Got file paths!", parsedFilepaths);207 fs.readFile(parsedFilepaths.first, { encoding: "UTF8" }, function(208 err,209 contentFirst210 ) {211 if (err) {212 throw err;213 }214 console.log("Got first file", contentFirst);215 fs.readFile(parsedFilepaths.second, { encoding: "UTF8" }, function(216 err,217 contentSecond218 ) {219 if (err) {220 throw err;221 }222 console.log("Got second file", contentSecond);223 fs.readFile(224 `./${parsedFilepaths.three}`,225 { encoding: "UTF8" },226 function(err, contentThird) {227 if (err) {228 throw err;229 }230 // OOOPS - undefined!231 console.log("Got third file", contentThird);232 }233 );234 });235 });236 }237);...

Full Screen

Full Screen

server.js

Source:server.js Github

copy

Full Screen

...10function doRequest(req, res) {11 var url = req.url;12 console.log(url);13 if ('/' == url || '/index.html' == url) {14 fs.readFile('./index.html', 'UTF-8', function (err, data) {15 res.writeHead(200, {'Content-Type': 'text/html'});16 res.write(data);17 res.end();18 });19 }else if('/test.html' == url) {20 fs.readFile('./test.html', 'UTF-8', function (err, data) {21 res.writeHead(200, {'Content-Type': 'text/html'});22 res.write(data);23 res.end();24 });25 }else if('/img/icon.jpeg' == url) {26 fs.readFile('./'+url, {encoding: null},function (err, data) {27 res.writeHead(200, {'Content-Type': 'image/jpeg'});28 res.write(data);29 res.end();30 });31 }else if('/img/icon.png' == url) {32 fs.readFile('./'+url, {encoding: null},function (err, data) {33 res.writeHead(200, {'Content-Type': 'image/png'});34 res.write(data);35 res.end();36 });37 } else if('/img/setting.png' == url) {38 fs.readFile('./'+url, {encoding: null},function (err, data) {39 res.writeHead(200, {'Content-Type': 'image/png'});40 res.write(data);41 res.end();42 });43 } else if('/img/microphone-on.png' == url) {44 fs.readFile('./'+url, {encoding: null},function (err, data) {45 res.writeHead(200, {'Content-Type': 'image/png'});46 res.write(data);47 res.end();48 });49 } else if('/img/present.png' == url) {50 fs.readFile('./'+url, {encoding: null},function (err, data) {51 res.writeHead(200, {'Content-Type': 'image/png'});52 res.write(data);53 res.end();54 });55 } else if('/img/camera.png' == url) {56 fs.readFile('./'+url, {encoding: null},function (err, data) {57 res.writeHead(200, {'Content-Type': 'image/png'});58 res.write(data);59 res.end();60 });61 } else if('/img/microphone.png' == url) {62 fs.readFile('./'+url, {encoding: null},function (err, data) {63 res.writeHead(200, {'Content-Type': 'image/png'});64 res.write(data);65 res.end();66 });67 } else if('/img/ng.png' == url) {68 fs.readFile('./'+url, {encoding: null},function (err, data) {69 res.writeHead(200, {'Content-Type': 'image/png'});70 res.write(data);71 res.end();72 });73 } else if('/obj/model.obj' == url) {74 fs.readFile('./'+url, {encoding: null},function (err, data) {75 res.writeHead(200, {'Content-Type': 'text/plain'});76 res.write(data);77 res.end();78 });79 } else if('/obj/materials.mtl' == url) {80 fs.readFile('./'+url, {encoding: null},function (err, data) {81 res.writeHead(200, {'Content-Type': 'text/plain'});82 res.write(data);83 res.end();84 });85 } else if('/obj/Beer.obj' == url) {86 fs.readFile('./'+url, {encoding: null},function (err, data) {87 res.writeHead(200, {'Content-Type': 'text/plain'});88 res.write(data);89 res.end();90 });91 } else if('/obj/Beer.mtl' == url) {92 fs.readFile('./'+url, {encoding: null},function (err, data) {93 res.writeHead(200, {'Content-Type': 'text/plain'});94 res.write(data);95 res.end();96 });97 } else if('/obj/Beer_BaseColor.png' == url) {98 fs.readFile('./'+url, {encoding: null},function (err, data) {99 res.writeHead(200, {'Content-Type': 'image/png'});100 res.write(data);101 res.end();102 });103 } else if('/wav/beer0.wav' == url) {104 fs.readFile('./'+url, {encoding: null},function (err, data) {105 res.writeHead(200, {'Content-Type': 'audio/wav'});106 res.write(data);107 res.end();108 });109 } else if('/wav/beer1.wav' == url) {110 fs.readFile('./'+url, {encoding: null},function (err, data) {111 res.writeHead(200, {'Content-Type': 'audio/wav'});112 res.write(data);113 res.end();114 });115 } else if('/wav/beer2.wav' == url) {116 fs.readFile('./'+url, {encoding: null},function (err, data) {117 res.writeHead(200, {'Content-Type': 'audio/wav'});118 res.write(data);119 res.end();120 });121 } else if('/wav/touch0.wav' == url) {122 fs.readFile('./'+url, {encoding: null},function (err, data) {123 res.writeHead(200, {'Content-Type': 'audio/wav'});124 res.write(data);125 res.end();126 });127 } else if('/wav/touch1.wav' == url) {128 fs.readFile('./'+url, {encoding: null},function (err, data) {129 res.writeHead(200, {'Content-Type': 'audio/wav'});130 res.write(data);131 res.end();132 });133 } else if('/wav/touch2.wav' == url) {134 fs.readFile('./'+url, {encoding: null},function (err, data) {135 res.writeHead(200, {'Content-Type': 'audio/wav'});136 res.write(data);137 res.end();138 });139 } else if('/wav/touch3.wav' == url) {140 fs.readFile('./'+url, {encoding: null},function (err, data) {141 res.writeHead(200, {'Content-Type': 'audio/wav'});142 res.write(data);143 res.end();144 });145 } else if('/wav/touch4.wav' == url) {146 fs.readFile('./'+url, {encoding: null},function (err, data) {147 res.writeHead(200, {'Content-Type': 'audio/wav'});148 res.write(data);149 res.end();150 });151 } else if('/bot' == url) {152 } else if('/tts' == url) {153 var data = require('./tts.js');154 function callback(options, convertText) {155 res.writeHead(200, {'Content-Type': 'audio/x-wav'});156 res.on('end', function(){157 res.end();158 });159 request(options, convertText).pipe(res)160 }161 var body = '';162 req.on('data', function (d) {163 body += d;164 if (body.length > 1e6) {165 request.connection.destroy();166 }167 }).on('end', function () {168 var post = JSON.parse(body);169 console.log(post['data']);170 data.tts(post['data'], callback);171 });172 } else if('/js/test.js' == url) {173 fs.readFile('./'+url, 'UTF-8',function (err, data) {174 res.writeHead(200, {'Content-Type': 'text/plain'});175 res.write(data);176 res.end();177 });178 } else if('/index.js' == url) {179 fs.readFile('./'+url, 'UTF-8',function (err, data) {180 res.writeHead(200, {'Content-Type': 'text/plain'});181 res.write(data);182 res.end();183 });184 } else if('/js/microsoft.cognitiveservices.speech.sdk.bundle-min.js' == url) {185 fs.readFile('./js/microsoft.cognitiveservices.speech.sdk.bundle-min.js', 'UTF-8',function (err, data) {186 res.writeHead(200, {'Content-Type': 'text/plain'});187 res.write(data);188 res.end();189 });190 } else {191 fs.readFile('./'+url, 'UTF-8', function (err, data) {192 res.writeHead(404, {'Content-Type': 'text/plain'});193 res.end();194 });195 }196}197server.listen(port);...

Full Screen

Full Screen

views.js

Source:views.js Github

copy

Full Screen

1var Views = module.exports;2var fs = require('fs')3Views.viewsDir = __dirname + '/../views'4Views.index = ''5indexPage = fs.readFile(Views.viewsDir + '/index.html', 'utf8',6 function (err, data) {7 Views.index += data8 });9Views.header = ''10headerPage = fs.readFile(Views.viewsDir + '/header.html', 'utf8',11 function (err, data) {12 Views.header += data13 });14Views.sidebar = ''15sidebarPage = fs.readFile(Views.viewsDir + '/sidebar.html', 'utf8',16 function (err, data) {17 Views.sidebar += data18 });19Views.login = ''20loginPage = fs.readFile(Views.viewsDir + '/login.html', 'utf8',21 function (err, data) {22 Views.login += data23 });24Views.dashboard = ''25dashboardPage = fs.readFile(Views.viewsDir + '/dashboard.html', 'utf8',26 function (err, data) {27 Views.dashboard += data28 });29Views.admin = ''30adminPage = fs.readFile(Views.viewsDir + '/admin.html', 'utf8',31 function (err, data) {32 Views.admin += data33 });34Views.accountActivated = ''35accountActivatedPage = fs.readFile(Views.viewsDir + '/accountActivated.html', 'utf8',36 function (err, data) {37 Views.accountActivated += data38 });39Views.clientAdmin = ''40clientAdminPage = fs.readFile(Views.viewsDir + '/clientAdmin.html', 'utf8',41 function (err, data) {42 Views.clientAdmin += data43 });44Views.user = ''45userPage = fs.readFile(Views.viewsDir + '/user.html', 'utf8',46 function (err, data) {47 Views.user += data48 });49Views.addUser = ''50adduserPage = fs.readFile(Views.viewsDir + '/addUser.html', 'utf8',51 function (err, data) {52 Views.addUser += data53 });54Views.client = ''55adminPage = fs.readFile(Views.viewsDir + '/client.html', 'utf8',56 function (err, data) {57 Views.client += data58 });59Views.addClient = ''60addClientPage = fs.readFile(Views.viewsDir + '/addClient.html', 'utf8',61 function (err, data) {62 Views.addClient += data63 });64Views.editClient = ''65editClientPage = fs.readFile(Views.viewsDir + '/editClient.html', 'utf8',66 function (err, data) {67 Views.editClient += data68 });69Views.editAccount = ''70editAccountPage = fs.readFile(Views.viewsDir + '/editAccount.html', 'utf8',71 function (err, data) {72 Views.editAccount += data73 });74Views.reallocateAccount = ''75reallocateAccountPage = fs.readFile(Views.viewsDir + '/reallocateAccount.html', 'utf8',76 function (err, data) {77 Views.reallocateAccount += data78 });79Views.did = ''80didPage = fs.readFile(Views.viewsDir + '/did.html', 'utf8',81 function (err, data) {82 Views.did += data83 });84Views.superReceptionist = ''85superReceptionistPage = fs.readFile(Views.viewsDir + '/superReceptionist.html', 'utf8',86 function (err, data) {87 Views.superReceptionist += data88 });89Views.addExtension = ''90addExtensionPage = fs.readFile(Views.viewsDir + '/addExtension.html', 'utf8',91 function (err, data) {92 Views.addExtension += data93 });94Views.superReceptionistList = ''95superReceptionistPage = fs.readFile(Views.viewsDir + '/superReceptionistList.html', 'utf8',96 function (err, data) {97 Views.superReceptionistList += data98 });99Views.editExtension = ''100editExtensionPage = fs.readFile(Views.viewsDir + '/editExtension.html', 'utf8',101 function (err, data) {102 Views.editExtension += data103 });104Views.clientDid = ''105clientDidPage = fs.readFile(Views.viewsDir + '/clientDid.html', 'utf8',106 function (err, data) {107 Views.clientDid += data108 });109Views.accountSummary = ''110accountPage = fs.readFile(Views.viewsDir + '/accountSummary.html', 'utf8',111 function (err, data) {112 Views.accountSummary += data113 });114Views.addAccount = ''115addAccountPage = fs.readFile(Views.viewsDir + '/addAccount.html', 'utf8',116 function (err, data) {117 Views.addAccount += data118 });119Views.report = ''120reportPage = fs.readFile(Views.viewsDir + '/report.html', 'utf8',121 function (err, data) {122 Views.report += data123 });124Views.inbox = ''125inboxPage = fs.readFile(Views.viewsDir + '/inbox.html', 'utf8',126 function (err, data) {127 Views.inbox += data128 });129Views.voicemail = ''130voicemailPage = fs.readFile(Views.viewsDir + '/voicemail.html', 'utf8',131 function (err, data) {132 Views.voicemail += data133 });134Views.addressbook = ''135addressbookPage = fs.readFile(Views.viewsDir + '/addressbook.html', 'utf8',136 function (err, data) {137 Views.addressbook += data138 });139Views.addDid = ''140addDidtPage = fs.readFile(Views.viewsDir + '/addDid.html', 'utf8',141 function (err, data) {142 Views.addDid += data143 });144Views.editDId = ''145editDidPage = fs.readFile(Views.viewsDir + '/editDid.html', 'utf8',146 function (err, data) {147 Views.editDid += data148 });149Views.changeSetting = ''150changeSettingPage = fs.readFile(Views.viewsDir + '/changeSetting.html', 'utf8',151 function (err, data) {152 Views.changeSetting += data153 });154Views.changePassword = ''155changePasswordPage = fs.readFile(Views.viewsDir + '/changePassword.html', 'utf8',156 function (err, data) {157 Views.changePassword += data158 });159Views.demoAccount = ''160demoAccountPage = fs.readFile(Views.viewsDir + '/demoAccount.html', 'utf8',161 function (err, data) {162 Views.demoAccount += data163 });164Views.addDemo = ''165addDemoPage = fs.readFile(Views.viewsDir + '/addDemo.html', 'utf8',166 function (err, data) {167 Views.addDemo += data168 });169Views.demoDashboard = ''170demoDashboardPage = fs.readFile(Views.viewsDir + '/demoDashboard.html', 'utf8',171 function (err, data){172 Views.demoDashboard += data173 });174Views.example = ''175examplePage = fs.readFile(Views.viewsDir + '/example.html', 'utf8',176 function (err, data) {177 Views.example += data178 });179Views.contactus = ''180contactus = fs.readFile(Views.viewsDir + '/contact.html', 'utf8',181 function (err, data) {182 Views.contactus += data183 });184Views.checkSocket = ''185checkSocket = fs.readFile(Views.viewsDir + '/checkSocket.html', 'utf8',186 function (err, data) {187 Views.checkSocket += data188 });189Views.editResources = ''190checkSocket = fs.readFile(Views.viewsDir + '/editResources.html', 'utf8',191 function (err, data) {192 Views.editResources += data193 });194Views.allocateDidForVR = ''195allocateDidForVRPage = fs.readFile(Views.viewsDir + '/allocateDidForVR.html', 'utf8',196 function (err, data) {197 Views.allocateDidForVR += data198 });199Views.createBWList = ''200createBWListPage = fs.readFile(Views.viewsDir + '/createBWList.html', 'utf8',201 function (err, data) {202 Views.createBWList += data203 });204Views.missedCall = ''205missedCallPage = fs.readFile(Views.viewsDir + '/missedCall.html', 'utf8',206 function (err, data) {207 Views.missedCall += data208 });209Views.stickyAgent = ''210stickyAgentPage = fs.readFile(Views.viewsDir + '/stickyAgent.html', 'utf8',211 function (err, data) {212 Views.stickyAgent += data...

Full Screen

Full Screen

test-esm-live-binding.mjs

Source:test-esm-live-binding.mjs Github

copy

Full Screen

...13syncBuiltinESMExports();14assert.deepStrictEqual([fs.readFile, readFile], [undefined, undefined]);15fs.readFile = fn;16syncBuiltinESMExports();17assert.deepStrictEqual([fs.readFile(), readFile()], [s, s]);18Reflect.defineProperty(fs, 'readFile', {19 value: fn,20 configurable: true,21 writable: true,22});23syncBuiltinESMExports();24assert.deepStrictEqual([fs.readFile(), readFile()], [s, s]);25Reflect.deleteProperty(fs, 'readFile');26syncBuiltinESMExports();27assert.deepStrictEqual([fs.readFile, readFile], [undefined, undefined]);28let count = 0;29Reflect.defineProperty(fs, 'readFile', {30 get() { return count; },31 configurable: true,32});33syncBuiltinESMExports();34assert.deepStrictEqual([readFile, fs.readFile], [0, 0]);35count++;36syncBuiltinESMExports();37assert.deepStrictEqual([fs.readFile, readFile], [1, 1]);38let otherValue;...

Full Screen

Full Screen

load-config-test.js

Source:load-config-test.js Github

copy

Full Screen

1/*eslint-env mocha*/2'use strict';3const fs = require('fs');4const sinon = require('sinon');5const config = require('../lib/config');6const Studio = require('../lib/studio');7const ENOENT = new Error('ENOENT');8ENOENT.code = 'ENOENT';9const EISDIR = new Error('EISDIR');10EISDIR.code = 'EISDIR';11describe('load-config', () => {12 let state;13 beforeEach(() => {14 sinon.stub(fs, 'readFile');15 sinon.stub(config, 'home').returns('~');16 state = new Studio({});17 sinon.stub(state, 'fail');18 sinon.stub(state, 'setConfig');19 });20 afterEach(() => {21 sinon.restore();22 delete process.env.XDG_CONFIG_HOME;23 });24 it('loads config from .studio', () => {25 state.loadConfig();26 sinon.assert.calledOnce(fs.readFile);27 sinon.assert.calledWith(fs.readFile, '.studio');28 });29 it('loads config from ~/.studio', () => {30 fs.readFile.withArgs('.studio').yields(ENOENT);31 state.loadConfig();32 sinon.assert.calledTwice(fs.readFile);33 sinon.assert.calledWith(fs.readFile, '~/.studio');34 });35 it('loads config from XDG_CONFIG_HOME', () => {36 process.env.XDG_CONFIG_HOME = '~/.xdg';37 fs.readFile.withArgs('.studio').yields(ENOENT);38 fs.readFile.withArgs('~/.studio').yields(ENOENT);39 state.loadConfig();40 sinon.assert.calledThrice(fs.readFile);41 sinon.assert.calledWith(fs.readFile, '~/.xdg/studio');42 });43 it('loads config from .config/studio', () => {44 fs.readFile.withArgs('.studio').yields(ENOENT);45 fs.readFile.withArgs('~/.studio').yields(ENOENT);46 state.loadConfig();47 sinon.assert.calledThrice(fs.readFile);48 sinon.assert.calledWith(fs.readFile, '~/.config/studio');49 });50 it('loads config from ~/.studio/config', () => {51 fs.readFile.withArgs('.studio').yields(EISDIR);52 fs.readFile.withArgs('~/.studio').yields(ENOENT);53 fs.readFile.withArgs('~/.config/studio').yields(ENOENT);54 state.loadConfig();55 sinon.assert.callCount(fs.readFile, 4);56 sinon.assert.calledWith(fs.readFile, '~/.studio/config');57 });58 it('fails if reading the config file fails', () => {59 fs.readFile.yields(new Error('Hell no'));60 state.loadConfig();61 sinon.assert.calledOnce(state.fail);62 sinon.assert.calledWith(state.fail, 'Failed to read config');63 });64 it('set config to empty object if none of the file locations exists', () => {65 fs.readFile.yields(ENOENT);66 state.loadConfig();67 sinon.assert.calledOnce(state.setConfig);68 sinon.assert.calledWith(state.setConfig, {});69 });70 it('sets config if .studio read succeeds', () => {71 fs.readFile.withArgs('.studio')72 .yields(null, '# Config\ntoken=123-456-789');73 state.loadConfig();74 sinon.assert.calledOnce(state.setConfig);75 sinon.assert.calledWith(state.setConfig, {76 token: '123-456-789'77 });78 });79 it('sets config if ~/.studio read succeeds', () => {80 fs.readFile.withArgs('.studio').yields(ENOENT);81 fs.readFile.withArgs('~/.studio')82 .yields(null, '# Config\ntoken=123-456-789');83 state.loadConfig();84 sinon.assert.calledOnce(state.setConfig);85 sinon.assert.calledWith(state.setConfig, {86 token: '123-456-789'87 });88 });...

Full Screen

Full Screen

app.js

Source:app.js Github

copy

Full Screen

...4co(function* () {5/*-------------------------------------start-series-part---------------------------------------------------*/6 var start = new Date();7 8 let s1 = yield fs.readFile('citylots.json'),9 s2 = yield fs.readFile('citylots.json'),10 s3 = yield fs.readFile('citylots.json'),11 s4 = yield fs.readFile('citylots.json'),12 s5 = yield fs.readFile('citylots.json'),13 s6 = yield fs.readFile('citylots.json'),14 s7 = yield fs.readFile('citylots.json');15 var end = new Date();16 console.log('series exec time: ', end - start)17/*---------------------------------------end-series-part---------------------------------------------------*/18/*-------------------------------------start-parallel-part-------------------------------------------------*/19 let p1 = fs.readFile('citylots.json'),20 p2 = fs.readFile('citylots.json'),21 p3 = fs.readFile('citylots.json'),22 p4 = fs.readFile('citylots.json'),23 p5 = fs.readFile('citylots.json'),24 p6 = fs.readFile('citylots.json'),25 p7 = fs.readFile('citylots.json');26 // you can run promises in parallel by yield them as array or object27 /*28 start = new Date();29 let paralizeByArr = yield [p1, p2, p3, p4, p5, p6]30 end = new Date();31 console.log('parallel "array_style" exec time: ', end - start)32 */33 start = new Date();34 let paralizeByObj = yield {35 first: p1,36 second: { sub1: p2, sub2: p3},37 third: { sub1: p4, sub2: {ssub1: p5, ssub2:{sssub1: p7}}}38 }39 end = new Date();...

Full Screen

Full Screen

async.js

Source:async.js Github

copy

Full Screen

2var fs = require('fs');3var start = (new Date()).getTime();4// async.parallel([5// function(callback){6// fs.readFile('file1.txt', 'utf-8', callback);7// },8// function (callback){9// fs.readFile('file2.txt', 'utf-8', callback);10// },11// function(callback){12// fs.readFile('file1.txt', 'utf-8', callback);13// },14// function (callback){15// fs.readFile('file2.txt', 'utf-8', callback);16// },17// function(callback){18// fs.readFile('file1.txt', 'utf-8', callback);19// },20// function (callback){21// fs.readFile('file2.txt', 'utf-8', callback);22// },23// function(callback){24// fs.readFile('file1.txt', 'utf-8', callback);25// },26// function (callback){27// fs.readFile('file2.txt', 'utf-8', callback);28// },29// function(callback){30// fs.readFile('file1.txt', 'utf-8', callback);31// },32// function (callback){33// fs.readFile('file2.txt', 'utf-8', callback);34// }35// ], function (err, results){36// console.log(results, (new Date()).getTime() - start);37// });38async.parallelLimit([39 function(callback){40 fs.readFile('file1.txt', 'utf-8', callback);41 },42 function (callback){43 fs.readFile('file2.txt', 'utf-8', callback);44 },45 function(callback){46 fs.readFile('file1.txt', 'utf-8', callback);47 },48 function (callback){49 fs.readFile('file2.txt', 'utf-8', callback);50 },51 function(callback){52 fs.readFile('file1.txt', 'utf-8', callback);53 },54 function (callback){55 fs.readFile('file2.txt', 'utf-8', callback);56 },57 function(callback){58 fs.readFile('file1.txt', 'utf-8', callback);59 },60 function (callback){61 fs.readFile('file2.txt', 'utf-8', callback);62 },63 function(callback){64 fs.readFile('file1.txt', 'utf-8', callback);65 },66 function (callback){67 fs.readFile('file2.txt', 'utf-8', callback);68 }69], 1, function (err, results){70 console.log(results, (new Date()).getTime() - start);...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1import { readFile } from 'fs';2import { promisify } from 'util';3const readFileAsync = promisify(readFile);4import { readFile } from 'fs/promises';5import { promises as fs } from 'fs';6const { readFile } = fs;7import { promises as fs } from 'fs';8const readFile = fs.readFile;

Full Screen

Using AI Code Generation

copy

Full Screen

1var fs = require('fs');2fs.readFile('test.txt', 'utf8', function(err, data) {3 if (err) throw err;4 console.log(data);5});6var fs = require('fs');7fs.writeFile('test.txt', 'Hello World', function(err, data) {8 if (err) throw err;9 console.log('File created successfully.');10});11var fs = require('fs');12fs.appendFile('test.txt', 'Hello World', function(err, data) {13 if (err) throw err;14 console.log('File created successfully.');15});16var fs = require('fs');17fs.unlink('test.txt', function(err, data) {18 if (err) throw err;19 console.log('File deleted successfully.');20});21var fs = require('fs');22fs.rename('test.txt', 'test1.txt', function(err, data) {23 if (err) throw err;24 console.log('File renamed successfully.');25});26var fs = require('fs');27fs.stat('test.txt', function(err, data) {28 if (err) throw err;29 console.log(data);30});31var fs = require('fs');32fs.mkdir('test', function(err, data) {33 if (err) throw err;34 console.log('Directory created successfully.');35});

Full Screen

Using AI Code Generation

copy

Full Screen

1var fs = require('fs');2var path = require('path');3var wd = require('wd');4var assert = require('assert');5var Q = require('q');6var chai = require('chai');7var chaiAsPromised = require('chai-as-promised');8chai.use(chaiAsPromised);9var should = chai.should();10var expect = chai.expect;11var _ = require('underscore');12var caps = {13};14var driver = wd.promiseChainRemote("

Full Screen

Using AI Code Generation

copy

Full Screen

1var fs = require('fs');2var file = fs.readFile('test.txt', 'utf8', function(err, data) {3 if (err) {4 console.log(err);5 }6 return data;7});8console.log(file);9var fs = require('fs');10var file = fs.createReadStream('test.txt', 'utf8');11console.log(file);12var fs = require('fs');13var file = fs.createReadStream('test.txt', 'utf8');14var count = 0;15file.on('data', function(chunk) {16 count += chunk.length;17});18file.on('end', function() {19 console.log(count);20});

Full Screen

Using AI Code Generation

copy

Full Screen

1var fs = require('fs');2var contents = fs.readFileSync('/Users/username/Desktop/file.txt', 'utf8');3fs.writeFile("/Users/username/Desktop/newfile.txt", contents, function(err) {4 if(err) {5 return console.log(err);6 }7 console.log("The file was saved!");8});

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Appium automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful