Usually learn Vuejs, Angularjs and other JS language, in the request Ajax, must go to configure IIS, more trouble, with this file, a small modification, you can run a server: http://localhost:3000/
Startorstop.bat
1 @echo off&setlocalenabledelayedexpansion2 REM #######################################################3 REM★★★★★ Note ★★★★★4 REM1. Add the user variable Node_path, point to the Global module directory node_modules--for example: E:\Skills\NodeJS\Data\node_global\node_modules5 REM2. Add global modules Koa and koa-static6 REMNPM I-g KOA7 REMnpm i-g koa-static8 REM3. Add Global module NPM29 REMnpm i-g npm2Ten REM ####################################################### One A REM###### can modify zone START - SetAppname=helloworld::App Name - SetAppscript=app.js::start the program, basically fixed unchanged the Setappserverport=3000::KOA Service port, note consistent with the ports defined in App.js - REM###### can modify area END - - + : Main - Echo1. (default) Start service http://localhost:%appserverport% + Echo2. Stop the current app service http://localhost:%appserverport%--has a residual process of PM2 node A Echo3.Stop all services-no residue process at Set/P option=Please select the Operation code: - - if notDefined optionGoto Start ::default jump to start - if%option%==1Goto Start - if%option%==2GotoDelete - if%option%==3GotoKill in - GotoError::other options, skip to Error to + - REM1. (default) Start service the : Start * Echo"Start browser ..." $ Start/HTTPlocalhost:%appserverport%Panax Notoginseng Echo"Start KOA service ..." -Pm2Start%appscript%--name%appname% the + A REM2. Stop the current app service the :d elete + PM2 Delete%appname% - $ $ REM3. Stop all services - : Kill - PM2 Kill the - Wuyi REM4. Select the error prompt the : Error - Echo############################################ Wu Echo########### Select Error, please re-select ########### - Echo############################################ About GotoMain
App.js
1' Use strict ';2 varServe = require (' koa-static '));3 varKOA = require (' KOA '));4 varApp =KOA ();5 varPort = 3000;6 7 //App.use (koa.static (__dirname + '/public '));8App.use (Serve ('. ')));9 TenApp.listen (Port,function(){ OneConsole.log (' Koa started successfully http://localhost: ' + port + '; press Ctrl-c to terminate. ' ); A});
BAT and js file package download: Http://files.cnblogs.com/files/chenshao/KoaPm2StaticServer.rar
Using KOA as a static file server (Windows)