-
Notifications
You must be signed in to change notification settings - Fork 0
/
hello.py
68 lines (50 loc) · 1.42 KB
/
hello.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
from flask import Flask
from flask import jsonify
import pandas as pd
import random
import os
from random import randrange
from pymongo import MongoClient
from flask import render_template
app = Flask(__name__)
@app.route('/graph')
def grapher():
return render_template('Event_Impact.html')
@app.route('/')
def hello_world():
return 'Hello Booboo !'
@app.route("/user")
def users():
my_user = os.environ['user']
msg = "user: " + my_user
return msg
@app.route("/mongo_data")
def mongo_data():
my_pass = os.environ['pass']
user_name = os.environ['user']
connection_string = "mongodb+srv://" + user_name + ":" + my_pass + "@project1.q26cg.mongodb.net/project1?retryWrites=true&w=majority"
try:
client = MongoClient(connection_string)
db = client.project1
collection = db.project1
query_mongo_df = pd.DataFrame(list(collection.find()))
first_20 = query_mongo_df.head(20)
except Exception as e:
return("error" + str(e))
return first_20.to_html()
@app.route("/pass")
def passes():
my_pass = os.environ['pass']
msg = "pass: " + my_pass
return msg
@app.route("/vars")
def vars():
my_vars = os.environ
my_vars_dict = dict(my_vars)
return jsonify(my_vars_dict)
@app.route("/random")
def random():
ret_val = "your random number is: " + str(randrange(100))
return ret_val
if __name__ == '__main__':
app.run()