├── .gitignore ├── Flask-wjr ├── aawsl.py ├── about.html ├── awsl.py ├── flask_server.py ├── post_request.py ├── receive.py └── request.py ├── LICENSE ├── README.md ├── STHacks-wtq ├── css │ └── styles.css ├── data │ ├── Canadian_Community_Hospitals.csv │ ├── CityofToronto_COVID-19_NeighbourhoodData.xlsx │ ├── Ministry_of_Health_Service_Provider_Locations.csv │ ├── all_hospitals_in_toronto.csv │ ├── all_pharmacies_in_toronto.csv │ ├── assessment_centre_locations.csv │ ├── covid_cases_total.csv │ └── toronto.geojson ├── index.html ├── js │ ├── d3 │ │ ├── API.md │ │ ├── CHANGES.md │ │ ├── LICENSE │ │ ├── README.md │ │ ├── d3.js │ │ └── d3.min.js │ └── vis.js ├── map.html └── vis.html ├── combined ├── .eslintignore ├── .eslintrc.js ├── .gitignore ├── .prettierignore ├── .prettierrc.json ├── app.js ├── config.js ├── controller │ ├── authController.js │ ├── locationController.js │ ├── mapController.js │ └── userInfoController.js ├── html │ ├── about.html │ ├── index.html │ ├── login.html │ ├── login_already.html │ ├── login_fail.html │ ├── login_success.html │ ├── map-conflict-b551fcc .html │ ├── map-support-b837266.html │ ├── map.html │ ├── signup.html │ ├── signup_already.html │ ├── signup_invalid_passwd.html │ ├── signup_success.html │ ├── support.html │ └── vis.html ├── model │ └── authModel.js ├── package.json ├── readme.md ├── routes │ ├── apiRoutes.js │ └── authRoutes.js ├── static │ ├── assets │ │ ├── bootstrap │ │ │ ├── css │ │ │ │ └── bootstrap.min.css │ │ │ └── js │ │ │ │ └── bootstrap.min.js │ │ ├── css │ │ │ ├── Features-Clean.css │ │ │ ├── Footer-Clean.css │ │ │ ├── Login-Form-Clean-1.css │ │ │ ├── Login-Form-Clean.css │ │ │ ├── Map-Clean.css │ │ │ ├── Navigation-with-Button.css │ │ │ ├── Search-Input-Responsive-with-Icon.css │ │ │ ├── mainCover.css │ │ │ └── styles.css │ │ ├── favicon.ico │ │ ├── fonts │ │ │ ├── FontAwesome.otf │ │ │ ├── fa-brands-400.eot │ │ │ ├── fa-brands-400.svg │ │ │ ├── fa-brands-400.ttf │ │ │ ├── fa-brands-400.woff │ │ │ ├── fa-brands-400.woff2 │ │ │ ├── fa-regular-400.eot │ │ │ ├── fa-regular-400.svg │ │ │ ├── fa-regular-400.ttf │ │ │ ├── fa-regular-400.woff │ │ │ ├── fa-regular-400.woff2 │ │ │ ├── fa-solid-900.eot │ │ │ ├── fa-solid-900.svg │ │ │ ├── fa-solid-900.ttf │ │ │ ├── fa-solid-900.woff │ │ │ ├── fa-solid-900.woff2 │ │ │ ├── font-awesome.min.css │ │ │ ├── fontawesome-all.min.css │ │ │ ├── fontawesome-webfont.eot │ │ │ ├── fontawesome-webfont.svg │ │ │ ├── fontawesome-webfont.ttf │ │ │ ├── fontawesome-webfont.woff │ │ │ ├── fontawesome-webfont.woff2 │ │ │ ├── fontawesome5-overrides.min.css │ │ │ ├── ionicons.eot │ │ │ ├── ionicons.min.css │ │ │ ├── ionicons.svg │ │ │ ├── ionicons.ttf │ │ │ └── ionicons.woff │ │ ├── img │ │ │ └── arch.jpg │ │ └── js │ │ │ └── jquery.min.js │ ├── css │ │ └── styles.css │ ├── data │ │ ├── Canadian_Community_Hospitals.csv │ │ ├── CityofToronto_COVID-19_NeighbourhoodData.xlsx │ │ ├── Ministry_of_Health_Service_Provider_Locations.csv │ │ ├── all_hospitals_in_toronto.csv │ │ ├── all_pharmacies_in_toronto.csv │ │ ├── assessment_centre_locations.csv │ │ ├── bloor-danforth-NAD83.csv │ │ ├── covid_cases_total.csv │ │ ├── sheppard-yonge-NAD83.csv │ │ ├── srt-NAD83.csv │ │ ├── toronto.geojson │ │ └── yonge-university-spadina-NAD83.csv │ ├── favicon.ico │ └── js │ │ ├── auth.js │ │ ├── d3 │ │ ├── API.md │ │ ├── CHANGES.md │ │ ├── LICENSE │ │ ├── README.md │ │ ├── d3.js │ │ └── d3.min.js │ │ └── vis.js ├── utils │ └── firebase.js └── yarn.lock ├── docs └── img │ ├── homepage.png │ └── logo.png ├── hackathon-01162-xxl ├── assets │ ├── bootstrap │ │ ├── css │ │ │ └── bootstrap.min.css │ │ └── js │ │ │ └── bootstrap.min.js │ ├── css │ │ ├── Footer-Clean.css │ │ ├── Login-Form-Clean-1.css │ │ ├── Login-Form-Clean.css │ │ ├── Map-Clean.css │ │ ├── Navigation-with-Button.css │ │ ├── Search-Input-Responsive-with-Icon.css │ │ ├── mainCover.css │ │ └── styles.css │ ├── fonts │ │ ├── fa-brands-400.eot │ │ ├── fa-brands-400.svg │ │ ├── fa-brands-400.ttf │ │ ├── fa-brands-400.woff │ │ ├── fa-brands-400.woff2 │ │ ├── fa-regular-400.eot │ │ ├── fa-regular-400.svg │ │ ├── fa-regular-400.ttf │ │ ├── fa-regular-400.woff │ │ ├── fa-regular-400.woff2 │ │ ├── fa-solid-900.eot │ │ ├── fa-solid-900.svg │ │ ├── fa-solid-900.ttf │ │ ├── fa-solid-900.woff │ │ ├── fa-solid-900.woff2 │ │ ├── fontawesome-all.min.css │ │ ├── ionicons.eot │ │ ├── ionicons.min.css │ │ ├── ionicons.svg │ │ ├── ionicons.ttf │ │ └── ionicons.woff │ ├── img │ │ └── arch.jpg │ └── js │ │ └── jquery.min.js ├── index.html ├── login.html ├── map.html ├── readme.md ├── requirements.txt ├── signup.html └── support.html └── python-xxl ├── .gitignore ├── .idea ├── .gitignore ├── inspectionProfiles │ ├── Project_Default.xml │ └── profiles_settings.xml ├── misc.xml ├── modules.xml ├── python-xxl.iml └── vcs.xml ├── cors.py ├── data ├── all_hospitals_in_toronto.csv ├── assessment_center_locations_utf8.csv ├── covid_cases_total.csv ├── covid_neighborhood_data.csv └── toronto.geojson ├── knn.py ├── predictor.py ├── readme.md └── rec.py /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store -------------------------------------------------------------------------------- /Flask-wjr/aawsl.py: -------------------------------------------------------------------------------- 1 | from flask import Flask, request 2 | 3 | app = Flask(__name__) 4 | 5 | 6 | @app.route('/') 7 | def hello_world(): 8 | return 'hello world' 9 | 10 | 11 | @app.route('/register', methods=['POST', 'GET']) 12 | def register(): 13 | if request.method == 'POST': 14 | print(request.headers) 15 | print(request.form) 16 | print(request.form['name']) 17 | print(request.form.get('name')) 18 | print(request.form.getlist('name')) 19 | print(request.form.get('nickname', default='little apple')) 20 | return 'welcome' 21 | 22 | 23 | if __name__ == '__main__': 24 | app.run(debug=True) 25 | -------------------------------------------------------------------------------- /Flask-wjr/about.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |
5 | 6 | 7 |Toronto is a crowded city with huge amounts of traffic. Everyday, over 2 million people commute to work, and possibly would expose to covid-19. We want to provide a one-shot solution to help people stay away from risks from infection, and help people make 42 | better commute decisions.
43 |47 |
Fine tuned Toronto covid data aren't readily available before we made it.
54 |We use APIs developed on our own to get up-to-date information about the covid.
58 |It aims to find the suitable route for customers with their commute preferences. Customize the trip with efficiency, convenience and safety.
62 |We provide the latest information about COVID-19, the Customized route for preventing potential risks. We are also able to recommend the nearest COVID-19 detecting point and hospital, and the analysis of drug stores. Moreover, we recommend the safe subway station given by travellers flows. From precaution to healing, we cover them all.
66 |We provide not only the efficient route for customers commuting to work, but also provide location of the nearest hospital and drug store options if customers feel uncomfortable. This would prevent infection in the first place.
70 |Customers are able to use this application through mobile devices easily. So people can receive the latest infromation by their mobile devices.
74 |abaaba
78 |Write this part after the project is almost done
83 |52 | Toronto is a crowded city with huge amounts of traffic. Everyday, over 2 million people commute 53 | to work, and possibly would expose to covid-19. We want to provide a one-shot solution to help 54 | people stay away from risks from infection, and help people make better commute decisions. 55 |
56 |66 | Fine tuned Toronto covid data aren't readily available before we made it. Our data 67 | visualization and algorithms are more informative and straightforward than simple 68 | charts. 69 |
70 |75 | We use APIs from various sources and recommendation systems develop on our own to get 76 | up-to-date information about the covid. 77 |
78 |83 | Our data visualization, map systems, and recommendation system are incorporated with 84 | well-designed query systems for Toronto. With APIs and relevant data provided, we can 85 | apply our design to every city in the world. 86 |
87 |92 | For more reliable performance and effective presentation of features, we choose to use 93 | lightweight frameworks such as Leaflet.js and jQuery in our design. 94 |
95 |Data is preprocessed and pulled only when needed.
100 |All data come from reliable and trackable sources.
105 |Write this part after the project is almost done
110 |Nullam id dolor id nibh ultricies vehicula ut id elit. Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec id elit non mi porta gravida at eget metus.
Nullam id dolor id nibh ultricies vehicula ut id elit. Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec id elit non mi porta gravida at eget metus.
Nullam id dolor id nibh ultricies vehicula ut id elit. Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec id elit non mi porta gravida at eget metus.
A prototype API for distant reading of science fiction novels.
''' 37 | 38 | @app.route('/foo', methods=['POST']) 39 | def foo(): 40 | response = flask.jsonify({'result': request.json}) 41 | response.headers.add('Access-Control-Allow-Origin', '*') 42 | return response 43 | 44 | @app.route('/api/v1/resources/books/all', methods=['GET']) 45 | def api_all(): 46 | return jsonify(books) 47 | 48 | 49 | @app.route('/api/v1/resources/books', methods=['GET']) 50 | def api_id(): 51 | # Check if an ID was provided as part of the URL. 52 | # If ID is provided, assign it to a variable. 53 | # If no ID is provided, display an error in the browser. 54 | if 'id' in request.args: 55 | id = int(request.args['id']) 56 | else: 57 | return "Error: No id field provided. Please specify an id." 58 | 59 | # Create an empty list for our results 60 | results = [] 61 | 62 | # Loop through the data and match results that fit the requested ID. 63 | # IDs are unique, but other fields might return many results 64 | for book in books: 65 | if book['id'] == id: 66 | results.append(book) 67 | 68 | # Use the jsonify function from Flask to convert our list of 69 | # Python dictionaries to the JSON format. 70 | return jsonify(results) 71 | 72 | app.run() 73 | -------------------------------------------------------------------------------- /python-xxl/rec.py: -------------------------------------------------------------------------------- 1 | import csv 2 | import math 3 | import knn, flask 4 | from flask import request, jsonify 5 | from flask_cors import CORS 6 | 7 | HOSPITALS = "./data/all_hospitals_in_toronto.csv" 8 | CASES = "./data/covid_cases_total.csv" 9 | COMMUNITY = "./data/covid_neighborhood_data.csv" 10 | ASSESSMENT = "./data/assessment_center_locations_utf8.csv" 11 | 12 | 13 | class communityNotFoundError(Exception): 14 | pass 15 | 16 | def get_assessment_list(coords): 17 | reader = csv.DictReader(open(ASSESSMENT, 'rt', encoding="utf8")) 18 | dict_list = [] 19 | for line in reader: 20 | if not line['longitude']: 21 | continue 22 | try: 23 | curr_coord = (float(line['longitude']), float(line['latitude'])) #这里和get_hospital_list不一样 24 | curr_dist = math.dist(curr_coord, coords) 25 | line['dist'] = curr_dist 26 | line['X'] = curr_coord[0] 27 | line['Y'] = curr_coord[1] 28 | dict_list.append(line) 29 | dict_list.append(line) 30 | except ValueError: 31 | continue 32 | return dict_list 33 | 34 | def get_hospital_list(coords): 35 | """coords: (x, y) 36 | return:[Dict(json)] 37 | """ 38 | reader = csv.DictReader(open(HOSPITALS, 'rt', encoding="utf8")) 39 | dict_list = [] 40 | for line in reader: 41 | x, y = float(line['\ufeffX']), float(line['Y']) 42 | curr_dist = math.dist((x,y), coords) 43 | line['dist'] = curr_dist 44 | 45 | line['X']=str(x) #修复开头的乱码 46 | # line.pop('\ufeffX', None) 47 | 48 | dict_list.append(line) 49 | return dict_list 50 | 51 | def get_cases_list(coords): 52 | """coords: (x, y) 53 | return:[Dict(json)] 54 | """ 55 | reader = csv.DictReader(open(CASES, 'rt', encoding="utf8")) 56 | dict_list = [] 57 | for line in reader: 58 | curr_coord = (float(line['X']), float(line['Y'])) #这里和get_hospital_list不一样 59 | curr_dist = math.dist(curr_coord, coords) 60 | line['dist'] = curr_dist 61 | dict_list.append(line) 62 | return dict_list 63 | 64 | 65 | def get_community_list(): 66 | reader = csv.DictReader(open(COMMUNITY, 'rt', encoding="utf8")) 67 | dict_list = [] 68 | for line in reader: 69 | dict_list.append(line) 70 | return dict_list 71 | 72 | def get_community_by_id(id:str): 73 | """输入id, 输出community json 74 | community的csv不大, 所以直接重复读取了 75 | """ 76 | com = get_community_list() 77 | 78 | for i in com: 79 | if id in i.values(): 80 | return i 81 | 82 | return None 83 | 84 | def get_community(com_id, com_list): 85 | curr_community = None # 找community json 86 | for com in com_list: 87 | if com['Neighbourhood ID'] == com_id: 88 | curr_community = com 89 | break 90 | if not curr_community: 91 | raise communityNotFoundError 92 | return curr_community 93 | 94 | 95 | def get_infection_rate_list(lst_sorted, count): 96 | """helper; 距离最近count个医院添加感染率信息 97 | lst:sorted: 按距离从小到大排列的所有医院 98 | """ 99 | com_list = get_community_list() 100 | rate_basis = lst_sorted[:count] 101 | 102 | clf = knn.get_classifier() 103 | for base in rate_basis: 104 | coords = (base['X'], base['Y']) 105 | com_id = knn.get_community(clf, coords) # 三位数str 106 | base['community'] = com_id 107 | curr_community = get_community(com_id, com_list) 108 | 109 | base['infection_rate'] = curr_community['Rate per 100,000 people'] 110 | return rate_basis 111 | 112 | 113 | def get_recommend(coord): 114 | """返回List[[json],[json],[json]] 115 | 对应最短路径, 最短路径walk-in, 感染率最低 116 | """ 117 | response = [] 118 | lst = get_assessment_list(coord) 119 | lst_sorted = sorted(lst, key=lambda k: k['dist']) # 距离从少到大排列 120 | response.append(lst_sorted[:3]) 121 | 122 | walk_ins = [] # 最短路径walk-in 123 | for i in lst_sorted: 124 | if i.get('walk_ins', None).lower() == 'yes' and len(walk_ins) < 3: 125 | walk_ins.append(i) 126 | response.append(walk_ins) 127 | 128 | rate_basis = get_infection_rate_list(lst_sorted, count=20) # 距离最近20个医院添加感染率信息 129 | rate_lst_sorted = sorted(rate_basis, key=lambda k: k['infection_rate']) 130 | response.append(rate_lst_sorted[:3]) 131 | 132 | return response 133 | 134 | def run_flask_server(): 135 | app = flask.Flask(__name__) 136 | app.config["DEBUG"] = True 137 | CORS(app) 138 | 139 | # @app.route('/foo', methods=['POST']) 140 | # def foo(): 141 | # response = flask.jsonify({'result': request.json}) 142 | # response.headers.add('Access-Control-Allow-Origin', '*') 143 | # return response 144 | 145 | @app.route('/foo', methods=['POST']) 146 | def recommend(): 147 | x, y = request.json['lac'], request.json['lng'] #TODO: 记得改回X和Y 148 | recommends = get_recommend((float(x), float(y))) 149 | 150 | response = flask.jsonify({'result': { 151 | 'nearest':recommends[0], 152 | 'nearest_walk_in':recommends[1], 153 | 'nearest_safest':recommends[2] 154 | }}) 155 | response.headers.add('Access-Control-Allow-Origin', '*') 156 | return response 157 | 158 | app.run() 159 | 160 | 161 | 162 | if __name__ == '__main__': 163 | 164 | print("flask server running...") 165 | run_flask_server() 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | --------------------------------------------------------------------------------