This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@app.route("/") | |
def login(): | |
#@"http://rescue-nfh.herokuapp.com/update_run" | |
return render_template("login.html") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// omitted code | |
@app.route("/process_login", methods=["POST"]) | |
def process_login(): | |
#user should be in db, so .get | |
user_name = request.form.get("user_name") | |
password = request.form.get("password") | |
email = request.form.get("email") | |
#going to search db for user_name and password | |
user = db_session.query(User).filter_by( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// omitted code | |
@app.route("/update_run", methods = ['POST']) | |
def update_run(): | |
if not request.json["user_name"]: | |
return json.dumps({ 'error': True }) | |
user_name = request.json['user_name'] #getting from iphone | |
password = request.json['password'] #getting from iphone | |
email = request.json['email'] #getting from iphone |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// omitted code | |
-(void)timerDidFire: (id)sender { | |
NFHLocationManager *locationManager = [NFHLocationManager sharedLocationManager]; | |
if(locationManager.updating) { | |
CLLocation *location = [locationManager lastLocation]; | |
[self updateInterfaceWithLocation:location]; | |
// BELOW - we send the coordinates to /update_run to the database in the web app | |
[[NFHWebServiceManager sharedWebServiceManager]sendUpdateRunRequestWithLocation:location]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// omitted code | |
-(void)timerDidFire: (id)sender { | |
NFHLocationManager *locationManager = [NFHLocationManager sharedLocationManager]; | |
if(locationManager.updating) { | |
CLLocation *location = [locationManager lastLocation]; | |
[self updateInterfaceWithLocation:location]; | |
// BELOW - we send the coordinates to /update_run to the database in the web app | |
[[NFHWebServiceManager sharedWebServiceManager]sendUpdateRunRequestWithLocation:location]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// omitted code | |
- (void)sendUpdateRunRequestWithLocation:(CLLocation *)location | |
{ | |
CLLocationCoordinate2D coordinate = [location coordinate]; | |
//accuracy is important | |
CLLocationAccuracy accuracy = location.horizontalAccuracy; | |
//my database in server has a created (timestamp) | |
// invert time b/c comes out to (-) | |
//distinguish between bad and good cordinates by setting parameters | |
if(location!=nil&&accuracy>0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// omitted code | |
@app.route("/contact_map_display/<user_id>", methods = ['GET']) | |
def contact_map_display(): | |
user_object = db_session.query(GPS_Location).filter_by(user_id=user_id).order_by(GPS_Location.created.desc()).first() | |
return render_template("contact_map.html", user_id = user_object.user_id) | |
// omitted code |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// omitted code | |
-(void)bean:(PTDBean*)bean serialDataReceived:(NSData*)data | |
{ | |
NSString *receivedMessage=[[NSString alloc]initWithData:data encoding:NSASCIIStringEncoding]; | |
NSLog (@"%@ this works", receivedMessage); | |
NFHLocationManager *locationManager = [NFHLocationManager sharedLocationManager]; | |
NFHWebServiceManager *webServiceManager = [NFHWebServiceManager sharedWebServiceManager]; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// omitted code | |
-(void)sendEmergencyRequest; | |
{ | |
NSMutableDictionary * dictOfCredentials = [[NSMutableDictionary alloc]init]; | |
NSURL *url = [NSURL URLWithString:@"http://rescue-nfh.herokuapp.com/emergency_run"]; //URL refer to hostName | |
[self sendRequestToURL:url requestBody:dictOfCredentials]; | |
} | |
// omitted code |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// omitted code | |
@app.route("/emergency_run", methods = ['POST']) | |
def emergency_message(): | |
textMessage("I have an emergency and need help. Please find me here: http://rescue-nfh.herokuapp.com/contact_map_display") | |
return json.dumps({ 'success': True }) | |
// omitted code |