Last active
January 21, 2020 22:46
-
-
Save ggodreau/fa8bff3af370fb870406a91223e78866 to your computer and use it in GitHub Desktop.
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
const express = require('express'); | |
const cors = require('cors'); | |
const functions = require('firebase-functions'); | |
const app = express() | |
const payload = ` | |
<!doctype html> | |
<html lang="en"> | |
<head> | |
<!-- Required meta tags --> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> | |
<!-- Bootstrap CSS --> | |
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous"> | |
</head> | |
<body> | |
<form method=post action="https://us-central1-imag-178020.cloudfunctions.net/mere_flask" enctype=multipart/form-data> | |
csv input: <input type=file name=raw_csv><br> | |
text input: <input type=text name=raw_text><br> | |
date input: <input type="date" name=raw_date><br> | |
<input type=submit value="do it"> | |
</form> | |
</body> | |
</html> | |
` | |
// landing page | |
app.get("/", (req, res) => { | |
res.set('Content-Type', 'text/html'); | |
res.status(200).send(new Buffer.from(payload)); | |
}); | |
// remove express trailing slash requirement from inbound url | |
// express requires trailing slash on the default endpoint, yuck | |
const merepage = functions.https.onRequest((request, response) => { | |
if (!request.path) { | |
request.url = `/${request.url}` // prepend '/' to keep query params if any | |
} | |
return app(request, response) | |
}) | |
module.exports = { | |
merepage | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment