This file contains hidden or 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
| const fs = require('fs'); | |
| const path = require('path'); | |
| module.exports = (app) => { | |
| fs.readdirSync('routes/api/').forEach((file) => { | |
| require(`./api/${file.substr(0, file.indexOf('.'))}`)(app); | |
| }) | |
| } |
This file contains hidden or 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.get('/search-location-weather', (req, res) => { | |
| //build api URL with user zip | |
| const baseUrl = 'http://api.openweathermap.org/data/2.5/weather?zip='; | |
| const apiId = '&appid=<YOUR API KEY GOES HERE>&units=imperial'; | |
| const userLocation = (url1, url2, zipcode) => { | |
| let newUrl = url1 + zipcode + url2; | |
| return newUrl; | |
| }; |
This file contains hidden or 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
| let zipcode; | |
| app.post('/search-location', (req, res) => { | |
| zipcode = req.body.zipcode; | |
| if(!zipcode || zipcode.length < 5 || zipcode.length > 5) { | |
| res.redirect('/error'); | |
| } else { | |
| res.redirect('/current-weather'); | |
| } |
This file contains hidden or 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
| const fetch = require('node-fetch'); | |
| module.exports = (app) => { | |
| let zipcode; | |
| app.post('/search-location', (req, res) => { | |
| zipcode = req.body.zipcode; |
This file contains hidden or 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
| const express = require('express'); | |
| const app = express(); | |
| const port = 5000; | |
| app.use(express.urlencoded({ extended: true })); | |
| app.use(express.json()); | |
| app.get('/', (req, res) => { | |
| res.send('PORT 5000'); | |
| }) |
This file contains hidden or 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
| import React, { Component } from 'react'; | |
| import logo from './logo.svg'; | |
| import './App.css'; | |
| class App extends Component { | |
| state = { | |
| data: null | |
| }; | |
| componentDidMount() { |
This file contains hidden or 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
| const express = require('express'); | |
| const app = express(); | |
| const port = process.env.PORT || 5000; | |
| // console.log that your server is up and running | |
| app.listen(port, () => console.log(`Listening on port ${port}`)); | |
| // create a GET route | |
| app.get('/express_backend', (req, res) => { | |
| res.send({ express: 'YOUR EXPRESS BACKEND IS CONNECTED TO REACT' }); |
This file contains hidden or 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
| #box1 { | |
| order: 2; | |
| } | |
| #box2{ | |
| order: 1; | |
| } | |
| #box3 { | |
| order: 4; | |
| } | |
| #box4{ |
This file contains hidden or 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
| .container { | |
| display: flex; | |
| flex-wrap: wrap; | |
| background: #1c9dc5; | |
| font-family: 'Rubik', sans-serif; | |
| height: 350px; | |
| width: 400px; | |
| } |
This file contains hidden or 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
| .container { | |
| display: flex; | |
| background: #1c9dc5; | |
| font-family: 'Rubik', sans-serif; | |
| } | |
| .box { | |
| border: solid #333 2px; | |
| background: #a8a8a8; | |
| height: 150px; |