-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
45 lines (28 loc) · 910 Bytes
/
app.py
File metadata and controls
45 lines (28 loc) · 910 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
38
39
40
41
42
43
44
45
import os
from flask import Flask, jsonify
from flask_cors import CORS
app = Flask(__name__, static_folder='./client/build/', static_url_path='/')
CORS(app, resources=r"/api/*", origins="http://localhost:3000")
# Routes
@app.route("/")
def react_app():
return app.send_static_file('index.html')
@app.route("/app")
def protected_react_app():
return app.send_static_file('index.html')
@app.route("/api/hello")
def hello_world():
return jsonify("Hello World!")
@app.route("/ping")
def ping():
return jsonify("pong")
# @app.errorhandler(404)
# def react_app(e):
# return app.send_static_file('index.html')
# Commands
@app.cli.command("build")
def build():
os.system("cd client & yarn build")
os.system("""pyinstaller --clean --onefile --icon=client/build/favicon.ico --add-data client/build/;client/build/ wsgi.py""")
if __name__ == "__main__":
app.run(debug=True)