-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathserver.py
More file actions
37 lines (25 loc) · 689 Bytes
/
server.py
File metadata and controls
37 lines (25 loc) · 689 Bytes
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
import os
from flask import Flask, render_template
from react.conf import settings
from react.render import render_component
app = Flask(__name__)
settings.configure(
RENDER=True,
RENDER_URL='http://127.0.0.1:9009/render'
)
TODOS = [
'Buy groceries',
'Mow the lawn',
'Take out the trash',
]
@app.route('/')
def index():
component = render_component(
os.path.join(os.getcwd(), 'static', 'TodoList.jsx'),
props={'todos': TODOS},
to_static_markup=False
)
return render_template('index.html', component=component)
if __name__ == '__main__':
port = int(os.environ.get('PORT', 5000))
app.run(host='0.0.0.0', port=port)