react-native-navigation的迁移库

local-docs.js 782B

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