Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
cc6bec5
Change flask static folder
roaga Nov 8, 2020
d671fd6
Add procfile
roaga Nov 8, 2020
de34821
Add gunicorn
roaga Nov 8, 2020
be9b5ea
Add flask to requirements
roaga Nov 8, 2020
ad1df15
Add flask_cors to requirements
roaga Nov 8, 2020
fb0f16b
Remove duplicate import
roaga Nov 8, 2020
68ebb6d
Fix CORS version number
roaga Nov 8, 2020
6692ca0
Add dotenv to requirements
roaga Nov 8, 2020
4f8c076
Change dotenv version
roaga Nov 8, 2020
a496a4a
Change dotenv
roaga Nov 8, 2020
e33e2df
Add IBM requirements
roaga Nov 8, 2020
e226369
Move build to root
roaga Nov 8, 2020
6a482e6
Remove localhost
roaga Nov 8, 2020
6d9c46a
Try window location hostname
roaga Nov 8, 2020
2563b60
Fix hostname
roaga Nov 8, 2020
9f80211
Update
roaga Nov 8, 2020
1326374
Log hostname
roaga Nov 8, 2020
73e7937
Add 0 host in app run
roaga Nov 8, 2020
3655ee4
Add port to app run
roaga Nov 8, 2020
e305427
Hardcode url
roaga Nov 8, 2020
1fa5283
Add static
roaga Nov 8, 2020
f244f9b
Remove static
roaga Nov 8, 2020
60bdc50
Change api path
roaga Nov 8, 2020
1311cfe
Tweak app.py
roaga Nov 8, 2020
3db6b61
Tweak again
roaga Nov 8, 2020
e6e4810
Revert
roaga Nov 8, 2020
17b1f96
Run npm install
roaga Nov 8, 2020
a751eb1
Rebuild
roaga Nov 8, 2020
29cdd93
Fix predict
roaga Nov 8, 2020
2ed2618
Fix predict
roaga Nov 8, 2020
2613717
Fix predict dimensions
roaga Nov 8, 2020
229139d
Fix squeeze
roaga Nov 8, 2020
310d2c4
Add latest models
roaga Nov 8, 2020
2a5d8d6
Rebuild with hostname
roaga Nov 8, 2020
7ca5d68
Rebuild
roaga Nov 8, 2020
a03477d
Change predict
roaga Nov 8, 2020
68de930
Rebuild
roaga Nov 8, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
web: gunicorn app:app --log-file=-
Binary file modified __pycache__/app.cpython-38.pyc
Binary file not shown.
15 changes: 7 additions & 8 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
from ibm_watson import NaturalLanguageUnderstandingV1
from ibm_cloud_sdk_core.authenticators import IAMAuthenticator
from ibm_watson.natural_language_understanding_v1 import Features, SentimentOptions, EntitiesOptions
from flask_cors import CORS

load_dotenv()
IBM_CLOUD_KEY = os.getenv('IBM_CLOUD_KEY')
Expand All @@ -24,14 +23,14 @@
)
natural_language_understanding.set_service_url('https://api.au-syd.natural-language-understanding.watson.cloud.ibm.com/instances/90774996-ec17-4440-b524-2c61f3a14481')

app = Flask(__name__)
app = Flask(__name__, static_folder="./build", static_url_path="/")
CORS(app)

@app.route('/')
def home():
return "Test Body"
return app.send_static_file('index.html')

@app.route('/features/<text>/<int:followers>/<int:friends>/<verified>')
@app.route('/api/features/<text>/<int:followers>/<int:friends>/<verified>')
def extractFeatures(text, followers, friends, verified):
text = text.replace("-", " ")
sentiment = 0.0
Expand Down Expand Up @@ -92,7 +91,7 @@ def extractFeatures(text, followers, friends, verified):
}
return(jsonify(dict))

@app.route("/predict/<features>", methods = ['GET','POST'])
@app.route("/api/predict/<features>", methods = ['GET','POST'])
def makePrediction(features):
features = json.loads(features.replace("-", " "))
# make prediction and return favorites, retweets, and whatever data we need for visualization
Expand All @@ -119,11 +118,11 @@ def makePrediction(features):

input_data = np.array(input_data).reshape(1, -1)

retweets = retweet_model.predict(input_data)
favorites = favorites_model.predict(input_data)
prediction = {"retweets": retweets[0, 0], "favorites": favorites[0, 0]}
retweets = retweet_model.predict(np.concatenate((input_data, favorites.reshape(-1,1)), axis=1))
prediction = {"retweets": np.squeeze(retweets)[()], "favorites": np.squeeze(favorites)[()]}

return(jsonify(prediction))

if __name__ == "__main__":
app.run()
app.run(host='0.0.0.0', port=5000)
23 changes: 23 additions & 0 deletions build/asset-manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"files": {
"main.css": "/static/css/main.21deee72.chunk.css",
"main.js": "/static/js/main.a77c807a.chunk.js",
"main.js.map": "/static/js/main.a77c807a.chunk.js.map",
"runtime-main.js": "/static/js/runtime-main.ef7b268d.js",
"runtime-main.js.map": "/static/js/runtime-main.ef7b268d.js.map",
"static/js/2.33047c05.chunk.js": "/static/js/2.33047c05.chunk.js",
"static/js/2.33047c05.chunk.js.map": "/static/js/2.33047c05.chunk.js.map",
"static/js/3.3bc0b7d3.chunk.js": "/static/js/3.3bc0b7d3.chunk.js",
"static/js/3.3bc0b7d3.chunk.js.map": "/static/js/3.3bc0b7d3.chunk.js.map",
"index.html": "/index.html",
"static/css/main.21deee72.chunk.css.map": "/static/css/main.21deee72.chunk.css.map",
"static/js/2.33047c05.chunk.js.LICENSE.txt": "/static/js/2.33047c05.chunk.js.LICENSE.txt",
"static/media/virus.f1500fda.png": "/static/media/virus.f1500fda.png"
},
"entrypoints": [
"static/js/runtime-main.ef7b268d.js",
"static/js/2.33047c05.chunk.js",
"static/css/main.21deee72.chunk.css",
"static/js/main.a77c807a.chunk.js"
]
}
Binary file added build/favicon.ico
Binary file not shown.
1 change: 1 addition & 0 deletions build/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="Web site created using create-react-app"/><link rel="apple-touch-icon" href="/logo192.png"/><link rel="manifest" href="/manifest.json"/><title>ViralCast</title><link href="/static/css/main.21deee72.chunk.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div><script>!function(e){function r(r){for(var n,i,a=r[0],c=r[1],l=r[2],p=0,s=[];p<a.length;p++)i=a[p],Object.prototype.hasOwnProperty.call(o,i)&&o[i]&&s.push(o[i][0]),o[i]=0;for(n in c)Object.prototype.hasOwnProperty.call(c,n)&&(e[n]=c[n]);for(f&&f(r);s.length;)s.shift()();return u.push.apply(u,l||[]),t()}function t(){for(var e,r=0;r<u.length;r++){for(var t=u[r],n=!0,a=1;a<t.length;a++){var c=t[a];0!==o[c]&&(n=!1)}n&&(u.splice(r--,1),e=i(i.s=t[0]))}return e}var n={},o={1:0},u=[];function i(r){if(n[r])return n[r].exports;var t=n[r]={i:r,l:!1,exports:{}};return e[r].call(t.exports,t,t.exports,i),t.l=!0,t.exports}i.e=function(e){var r=[],t=o[e];if(0!==t)if(t)r.push(t[2]);else{var n=new Promise((function(r,n){t=o[e]=[r,n]}));r.push(t[2]=n);var u,a=document.createElement("script");a.charset="utf-8",a.timeout=120,i.nc&&a.setAttribute("nonce",i.nc),a.src=function(e){return i.p+"static/js/"+({}[e]||e)+"."+{3:"3bc0b7d3"}[e]+".chunk.js"}(e);var c=new Error;u=function(r){a.onerror=a.onload=null,clearTimeout(l);var t=o[e];if(0!==t){if(t){var n=r&&("load"===r.type?"missing":r.type),u=r&&r.target&&r.target.src;c.message="Loading chunk "+e+" failed.\n("+n+": "+u+")",c.name="ChunkLoadError",c.type=n,c.request=u,t[1](c)}o[e]=void 0}};var l=setTimeout((function(){u({type:"timeout",target:a})}),12e4);a.onerror=a.onload=u,document.head.appendChild(a)}return Promise.all(r)},i.m=e,i.c=n,i.d=function(e,r,t){i.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:t})},i.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},i.t=function(e,r){if(1&r&&(e=i(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var t=Object.create(null);if(i.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var n in e)i.d(t,n,function(r){return e[r]}.bind(null,n));return t},i.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return i.d(r,"a",r),r},i.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},i.p="/",i.oe=function(e){throw console.error(e),e};var a=this.webpackJsonphackrpi2020=this.webpackJsonphackrpi2020||[],c=a.push.bind(a);a.push=r,a=a.slice();for(var l=0;l<a.length;l++)r(a[l]);var f=c;t()}([])</script><script src="/static/js/2.33047c05.chunk.js"></script><script src="/static/js/main.a77c807a.chunk.js"></script></body></html>
Binary file added build/logo192.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added build/logo512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 25 additions & 0 deletions build/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"short_name": "React App",
"name": "Create React App Sample",
"icons": [
{
"src": "favicon.ico",
"sizes": "64x64 32x32 24x24 16x16",
"type": "image/x-icon"
},
{
"src": "logo192.png",
"type": "image/png",
"sizes": "192x192"
},
{
"src": "logo512.png",
"type": "image/png",
"sizes": "512x512"
}
],
"start_url": ".",
"display": "standalone",
"theme_color": "#000000",
"background_color": "#ffffff"
}
3 changes: 3 additions & 0 deletions build/robots.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# https://www.robotstxt.org/robotstxt.html
User-agent: *
Disallow:
2 changes: 2 additions & 0 deletions build/static/css/main.21deee72.chunk.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions build/static/css/main.21deee72.chunk.css.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions build/static/js/2.33047c05.chunk.js

Large diffs are not rendered by default.

41 changes: 41 additions & 0 deletions build/static/js/2.33047c05.chunk.js.LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
object-assign
(c) Sindre Sorhus
@license MIT
*/

/** @license React v0.20.1
* scheduler.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

/** @license React v17.0.1
* react-dom.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

/** @license React v17.0.1
* react-jsx-runtime.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

/** @license React v17.0.1
* react.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
1 change: 1 addition & 0 deletions build/static/js/2.33047c05.chunk.js.map

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions build/static/js/3.3bc0b7d3.chunk.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading