-
Notifications
You must be signed in to change notification settings - Fork 43
/
server.py
32 lines (26 loc) · 851 Bytes
/
server.py
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
from flask import Flask, send_file
import os
import json
from analyzer import analyzeSymbol
app = Flask(__name__)
# serve all resources from static directory
@app.route('/js/<path:path>')
def js_proxy(path):
return send_file(os.path.join('public/js/', path))
@app.route('/partials/<path:path>')
def partials_proxy(path):
return send_file(os.path.join('public/partials/', path))
@app.route('/css/<path:path>')
def css_proxy(path):
return send_file(os.path.join('public/css/', path))
# API routes
@app.route('/api/analyze/<stockSymbol>')
def apiAnalyze(stockSymbol):
return json.dumps(analyzeSymbol(stockSymbol))
# leave frontend routing up to Angular
@app.route('/', defaults={'p': ''})
@app.route('/<path:p>')
def angularApp(p = None):
return send_file('public/index.html')
if __name__ == '__main__':
app.run(debug=True)