Jerry Zhang
Created July 12, 2020 © MIT

Social Distancing Detector

Find out how crowded a location is before visiting to stay safe! The system will detect people and display the information on a map.

AdvancedFull instructions provided20 hours10

Things used in this project

Hardware components

balenaFin
balenaFin
×1
Webcam, Logitech® HD Pro
Webcam, Logitech® HD Pro
Or any other compatible webcam
×1

Software apps and online services

AWS Lambda
Amazon Web Services AWS Lambda

Story

Read more

Code

server.js

JavaScript
Main Backend Server code file
const express = require("express");
const mongoose = require("mongoose");
const bodyParser = require("body-parser");
const passport = require("passport");
const users = require("./routes/api/users");
const sensors = require("./routes/api/sensors");
const app = express();
// const cors = require('cors');

// Bodyparser middleware
app.use(
  bodyParser.urlencoded({
    extended: false
  })
);
app.use(bodyParser.json());

// DB Config
const db = require("./config/keys").mongoURI;

// Connect to MongoDB
mongoose
  .connect(
    db,
    { useNewUrlParser: true }
  )
  .then(() => console.log("MongoDB successfully connected"))
  .catch(err => console.log(err));

// Passport middleware
app.use(passport.initialize());

// Passport config
require("./config/passport")(passport);

// Routes


app.use("/api/users", users);
app.use("/api/sensors", sensors);

// app.use(cors()); // not sure if necessary

const port = process.env.PORT || 5000;

app.listen(port, () => console.log(`Server up and running on port ${port}`));

Credits

Jerry Zhang

Jerry Zhang

10 projects • 13 followers
Thanks to Adrian from PyImageSearch.

Comments