def index(): handle = request.args.get("handle") if handle == None: return render_template("index.html") else: data = pydb.LogiticaPolitica().getAll() newUser = udc.UserData() newUser.updateHandle(handle) tweets = twitData.getTweets(handle) newUser.updateRealName(tweets[0]) newUser.updateOpinion(tweets[1]) newUser.updateMood(newUser.askInfo("mood", "string")) curMood = newUser.mood curMood = curMood.title() newUser.updateParty(newUser.askInfo("party", "string")) newUser.addToDB() eStuff = newUser.compareWithParty() amountError = eStuff[0] amountError = round(amountError * 100, 2) emotionsParty = eStuff[1] interpretError = newUser.interpretError(amountError) partyConfidence = newUser.percentParty() print(partyConfidence) #Important interface # return str((newUser.twitterHandle, newUser.realName, newUser.opinionString, newUser.mood, newUser.politicalParty)) # listOf(dictOf(Dict) Float listOf(float) Str Str Str Str return render_template("results.html", data=data, amountError=amountError, emotionsParty=emotionsParty, interpretError=interpretError, handle=newUser.twitterHandle, name=newUser.realName, tweet=newUser.opinionString, mood=curMood, party=newUser.politicalParty, partyConfidence=partyConfidence)
def index(): print("a") data = pydb.LogiticaPolitica().getAll() print(data) return render_template("index.html", data = data)
from flask import Flask, render_template import pyredb as pydb app = Flask(__name__) @app.route("/") def index(): print("a") data = pydb.LogiticaPolitica().getAll() print(data) return render_template("index.html", data = data) if __name__ == "__main__": pydb.LogiticaPolitica().start() app.run()
""" # ------------------------------------------------------------------------------------------------------------------ # End of Database Operations if __name__ == "__main__": #Tests # get api keys securely config = {} with open("config.py") as f: code = compile(f.read(), "config.py", 'exec') exec(code, config) f.close() firedb = pydb.LogiticaPolitica() # Test each individual operation. """ basicTest1 = UserData() # print(basicTest1) userHandle = "ethguo" basicTest1.updateHandle(userHandle) # basicTest1.updateOpinion("I have an opinion") # print(basicTest1) tdata = twitData.getTweets(basicTest1.twitterHandle) basicTest1.updateOpinion(tdata[1]) basicTest1.updateRealName(tdata[0]) print("asdasdsadsadas") print(basicTest1.opinionString) # print(basicTest1)
def index(): data = pydb.LogiticaPolitica().getAll() #data = "asdad" return render_template("index.html", data=data)