From e787b357b5d9e59bbfe6ed0d1307daf7a57ad60b Mon Sep 17 00:00:00 2001 From: mgerb42 Date: Wed, 1 Jun 2016 19:36:35 -0500 Subject: [PATCH 1/9] updated readme --- readme.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/readme.md b/readme.md index 6860c0f..dcd4ea5 100644 --- a/readme.md +++ b/readme.md @@ -1 +1,5 @@ -## Converting to Go back end and Angular front end +# Golang Site Implementation + +I have been working on converting my entire website over to the Go programming language. Along with doing this I have also converted the front end entirely to AngularJS. MongoDB is still used and the data base queries have been more optimized. + +I have also made this project open source. Passwords are no longer stored in the code. Rename "config-template.json" to "config.json" to start the server. From 2c2bc8d43d7ffc179e366cda113f6a62978aaaac Mon Sep 17 00:00:00 2001 From: Mitchell Gerber Date: Thu, 21 Jul 2016 15:25:37 -0500 Subject: [PATCH 2/9] Update resume.html --- public/posts/resume.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/posts/resume.html b/public/posts/resume.html index e476621..bf5b289 100644 --- a/public/posts/resume.html +++ b/public/posts/resume.html @@ -83,7 +83,7 @@ From 60ab8531261fcfc7980c37842703d6f7e4120121 Mon Sep 17 00:00:00 2001 From: Mitchell Gerber Date: Thu, 21 Jul 2016 15:26:01 -0500 Subject: [PATCH 3/9] Update 1-1-16.html --- public/posts/1-1-16.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/public/posts/1-1-16.html b/public/posts/1-1-16.html index c8be7ab..9c02df2 100644 --- a/public/posts/1-1-16.html +++ b/public/posts/1-1-16.html @@ -18,7 +18,7 @@

Above is the GET request that is sent to the server from the ESP8266. Data is tranferred through GET parameters. The key is an authentication code that I set to prevent unwanted HTTP requests. This is similar to an API key. Below is the code implemented to handle the HTTP request from the ESP8266.

- +

Creating the REST API

@@ -31,7 +31,7 @@

Now that I know what information I need I can start developing my REST API. I have a MongoDB collection called "temperature", which stores temperature, humidity, location, and time updated. Updated is a type of Date, which I will use in all of the queries to group by each day. To do the grouping in MongoDB I needed to use the aggregation functionality of MongoDB. Aggregation allows me to essentially perform queries on top of queries using the MongoDB "pipeline". This is similar to an SQL query when a selection is performed within a selection.

- +

Explanation of MongoDB Queries

@@ -52,4 +52,4 @@

/api/sensorbylocation/year?location=Winona%20Apartment&year=2016

- \ No newline at end of file + From e8b45042a1362b5dccfaf77356beea9875cca620 Mon Sep 17 00:00:00 2001 From: Mitchell Gerber Date: Thu, 21 Jul 2016 15:26:17 -0500 Subject: [PATCH 4/9] Update 10-28-15.html --- public/posts/10-28-15.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/public/posts/10-28-15.html b/public/posts/10-28-15.html index 18a8600..1a15cef 100644 --- a/public/posts/10-28-15.html +++ b/public/posts/10-28-15.html @@ -24,10 +24,10 @@
-

Code can be found here.

+

Code can be found here.

- +

@@ -88,4 +88,4 @@
image2
- \ No newline at end of file + From 42d4c918fcea8406402946ea74fc36c386a0e206 Mon Sep 17 00:00:00 2001 From: Mitchell Gerber Date: Thu, 21 Jul 2016 15:26:45 -0500 Subject: [PATCH 5/9] Update 12-18-15.html --- public/posts/12-18-15.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/public/posts/12-18-15.html b/public/posts/12-18-15.html index d7dbc88..8a1d4b6 100644 --- a/public/posts/12-18-15.html +++ b/public/posts/12-18-15.html @@ -17,7 +17,7 @@

-

For this project you will need an ESP8266 and a DHT temperature sensor. For prototyping purposes I prefer to use the NodeMCU module. There are a variety of temperature sensors that you could use, but I prefer the DHT11 because it is easy to use and it is cheap! I ordered a 5 pack of them from Banggood. The source code for this project can be found on Github. +

For this project you will need an ESP8266 and a DHT temperature sensor. For prototyping purposes I prefer to use the NodeMCU module. There are a variety of temperature sensors that you could use, but I prefer the DHT11 because it is easy to use and it is cheap! I ordered a 5 pack of them from Banggood. The source code for this project can be found on Github.

How it works

@@ -46,5 +46,5 @@

Code

- - \ No newline at end of file + + From 140b520fe46d94364b0d7d95c84c4731be1b07fc Mon Sep 17 00:00:00 2001 From: Mitchell Gerber Date: Thu, 21 Jul 2016 15:27:12 -0500 Subject: [PATCH 6/9] Update 12-29-15.html --- public/posts/12-29-15.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/public/posts/12-29-15.html b/public/posts/12-29-15.html index 0afea14..fdb5ae0 100644 --- a/public/posts/12-29-15.html +++ b/public/posts/12-29-15.html @@ -23,10 +23,10 @@

There were a few other updates that I made. I realized that if the access point the ESP was connected to goes down, it would not try to reconnect. It will now check if it is connected to the access point every time it tries to take a temperature reading and send data. If it is not connected to the access point it will reboot. Now that it reboots, if it still cannot connect to the access point it will be stuck in config mode. I fixed this by creating a timeout. If it has been sitting in config mode for 10 minutes the device will reboot.

-

These example are show below. Keep in mind that this is not the entire program, but just the new functionality that I mentioned. The source code for the project can be found here. +

These example are show below. Keep in mind that this is not the entire program, but just the new functionality that I mentioned. The source code for the project can be found here.

- +

Problems flashing the ESP

I previously used the ESP-07, but recently got some new ESP-12e's because of the higher flash size. I thought this would be great if I was going to make use of the file system. After spending hours and hours trying to flash these chips, I came to the conclusion that I need a better serial to USB programmer. The current one that I use came from China and was very cheap. From 166e5f434a112eacfe7625e2749061daed6686ab Mon Sep 17 00:00:00 2001 From: Mitchell Gerber Date: Wed, 27 Jul 2016 22:39:05 -0500 Subject: [PATCH 7/9] Update route.go --- route/route.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/route/route.go b/route/route.go index dc6105f..5541161 100644 --- a/route/route.go +++ b/route/route.go @@ -23,7 +23,8 @@ func Routes() *httprouter.Router { r.GET("/discord", controller.DiscordRedirect) r.GET("/vpn", controller.VPNRedirect) - + r.GET("/camera", controller.CameraRedirect) + //set up public folder path r.ServeFiles("/public/*filepath", http.Dir("./public")) From db4dbed39bf0ca4608a2bfbe6866583e1d3ae693 Mon Sep 17 00:00:00 2001 From: Mitchell Gerber Date: Wed, 27 Jul 2016 22:40:39 -0500 Subject: [PATCH 8/9] Added new route --- controller/redirect.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/controller/redirect.go b/controller/redirect.go index bf2daaa..e477d21 100644 --- a/controller/redirect.go +++ b/controller/redirect.go @@ -7,14 +7,15 @@ import ( // Redirect to discord func DiscordRedirect(w http.ResponseWriter, r *http.Request, _ httprouter.Params) { - http.Redirect(w, r, "https://discordapp.com/invite/0Z2tzxKECEj2BHwj", 301) - } // Redirect to discord func VPNRedirect(w http.ResponseWriter, r *http.Request, _ httprouter.Params) { - http.Redirect(w, r, "https://mitchel.io:943", 301) - +} + +// Redirect to security cameras +func CameraRedirect(w http.ResponseWriter, r *http.Request, _ httprouter.Params) { + http.Redirect(w, r, "https://24.118.44.161:8080/html/", 301) } From fab785bd31ed8390b6ac67c8d552c693ba49fd97 Mon Sep 17 00:00:00 2001 From: mgerb Date: Wed, 27 Jul 2016 22:54:14 -0500 Subject: [PATCH 9/9] fixed redirect --- controller/redirect.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/controller/redirect.go b/controller/redirect.go index e477d21..e1437d2 100644 --- a/controller/redirect.go +++ b/controller/redirect.go @@ -17,5 +17,5 @@ func VPNRedirect(w http.ResponseWriter, r *http.Request, _ httprouter.Params) { // Redirect to security cameras func CameraRedirect(w http.ResponseWriter, r *http.Request, _ httprouter.Params) { - http.Redirect(w, r, "https://24.118.44.161:8080/html/", 301) + http.Redirect(w, r, "http://24.118.44.161:8080/html/", 301) }