-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
38 lines (28 loc) · 997 Bytes
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
var express = require('express');
var app = express();
var React = require('react');
require('node-jsx').install();
var ListApp = require('./app/components/ListApp');
var MyApp = React.createFactory(ListApp);
var ListContainer = require('./app/components/ListContainer');
var ListFactory = React.createFactory(ListContainer);
app.use(express.static(__dirname + '/public'));
app.get('/', function(req,res) {
res.setHeader('Content-Type', 'text/html');
res.write("<!DOCTYPE html>");
//Renders without React IDS
res.end(React.renderToStaticMarkup(MyApp(
{html: React.renderToString(ListFactory())
})));
});
app.get('/titlefromserver', function(req,res) {
res.setHeader('Content-Type', 'text/html');
res.write("<!DOCTYPE html>");
//Renders without React IDS
res.end(React.renderToStaticMarkup(MyApp({
metaTitle: "TitleFromServer",
html: React.renderToString(ListFactory())
})));
});
app.listen(3333);
console.log("Server running at, localhost:3333");