This gist is part of a blog post. Check it out at:
http://jasonrudolph.com/blog/2011/08/09/programming-achievements-how-to-level-up-as-a-developer
This gist is part of a blog post. Check it out at:
http://jasonrudolph.com/blog/2011/08/09/programming-achievements-how-to-level-up-as-a-developer
| [{ | |
| "duration": 12637839, | |
| "release_day": null, | |
| "permalink_url": "http://soundcloud.com/jwagener/sets/concerts", | |
| "genre": null, | |
| "permalink": "concerts", | |
| "purchase_url": null, | |
| "release_month": null, | |
| "description": null, | |
| "uri": "https://api.soundcloud.com/playlists/215461645", |
| const express = require('express'); | |
| const ejs = require('ejs'); | |
| // Import environmental variables from the variables.env file | |
| require('dotenv').config({ path: 'variables.env' }); | |
| // Logger | |
| const log = console.log.bind(console); | |
| // Init app |
| <!DOCTYPE html> | |
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <meta http-equiv="X-UA-Compatible" content="ie=edge"> | |
| <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.100.2/css/materialize.min.css"> | |
| <title>Upload Image</title> |
| app.post('/upload', (req, res) => { | |
| upload(req, res, (err) => { | |
| if (err) { | |
| res.render('index', { | |
| msg: err | |
| }); | |
| } else { | |
| if (req.file == undefined) { | |
| res.render('index', { | |
| msg: 'Error: No File Selected!' |
| // Set The Storage Engine | |
| const storage = multer.diskStorage({ | |
| destination: './public/uploads/', | |
| filename: (req, file, cb) => { | |
| cb(null, file.fieldname + '-' + Date.now() + path.extname(file.originalname)); | |
| } | |
| }); | |
| // Init Upload | |
| const upload = multer({ |
Picking the right architecture = Picking the right battles + Managing trade-offs