-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathServer.py
46 lines (35 loc) · 1.62 KB
/
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import cherrypy
import dashboard
class StockServer(object):
@cherrypy.expose
def index(self, stockSYM=""):
LandingPageFile = open("LandingPage.html", "r")
'''
if we don't have an inputted stock, then we want the default page
which tells the user what to do
'''
if stockSYM == "":
return LandingPageFile.read()
splitGET = stockSYM.split()
if len(splitGET) < 2:
return "ERROR: PLEASE ENTER IN THE CORRECT FORMAT"
inputtedStock = splitGET[0]
inputtedSample = splitGET[1]
'''
We do have an inputted stock symbol, so now we need to
generate the dashboards, which we will then serve.
'''
DashboardHomeFile = open("DashboardHome.html", "r")
DashboardHome = DashboardHomeFile.read()
try:
polarityScript, polarityHtml, biasScript, biasHtml, relScript, relHtml = dashboard.makeDashboards(inputtedStock, int(inputtedSample))
except:
return "ERROR: PLEASE ENTER A STOCK SYMBOL THAT EXISTS."
DashboardHome = DashboardHome.replace("{{polarityScript}}", polarityScript)
DashboardHome = DashboardHome.replace("{{polarityHtml}}", polarityHtml)
DashboardHome = DashboardHome.replace("{{biasScript}}", biasScript)
DashboardHome = DashboardHome.replace("{{biasHtml}}", biasHtml)
DashboardHome = DashboardHome.replace("{{relScript}}", relScript)
DashboardHome = DashboardHome.replace("{{relHtml}}", relHtml)
return DashboardHome
cherrypy.quickstart(StockServer())