react-native-navigation的迁移库

local-docs.js 814B

123456789101112131415161718192021222324252627282930313233
  1. /* tslint:disable: no-console */
  2. const http = require('http');
  3. const fs = require('fs');
  4. const PORT = 3000;
  5. const ROOT = `${__dirname}/../docs`;
  6. run();
  7. function run() {
  8. http.createServer((req, res) => {
  9. console.log(req.url);
  10. const path = `${ROOT}${req.url === '/' ? '/index.html' : req.url}`;
  11. fs.readFile(path, (err, data) => {
  12. if (err) {
  13. console.error(err);
  14. res.writeHead(404, err.message);
  15. } else {
  16. res.writeHead(200, {
  17. 'Content-Type': 'text/html',
  18. 'Cache-Control': 'private, no-cache, no-store, must-revalidate',
  19. 'Expires': '-1',
  20. 'Pragma': 'no-cache'
  21. });
  22. res.write(data);
  23. }
  24. res.end();
  25. });
  26. }).listen(PORT, () => {
  27. console.log(`Listening for ${ROOT} on localhost:${PORT}`);
  28. });
  29. }