finished demo. ready for deployment

This commit is contained in:
Om Raheja 2024-05-18 16:15:20 -04:00
parent e7b4eaac0b
commit 18b0dd0e47
3 changed files with 21 additions and 3 deletions

15
app.js
View File

@ -31,6 +31,21 @@ app.get('/script.js', (req, res) => {
}); });
app.get('/YOUR_IMAGE.jpg', (req, res) => {
const imagePath = __dirname + '/static/YOUR_IMAGE.jpg';
const imageStats = fs.statSync(imagePath);
const fileSize = imageStats.size;
const imageType = 'image/jpeg';
// Set the 'Content-Type' header with the correct MIME type
res.setHeader('Content-Type', imageType);
// Set the 'Content-Length' header with the file size
res.setHeader('Content-Length', fileSize);
// Pipe the image file to the response
const imageStream = fs.createReadStream(imagePath);
imageStream.pipe(res);
});
app.post('/completions', async (req, res) => { app.post('/completions', async (req, res) => {
try { try {
const query = req.body.query; const query = req.body.query;

BIN
static/YOUR_IMAGE.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 179 KiB

View File

@ -6,14 +6,17 @@
<title>Upload Image</title> <title>Upload Image</title>
</head> </head>
<body> <body>
<input type="file" id="imageInput" accept="image/*" required=""> <button onclick="uploadImage()" id="upload-image-btn">Upload Image</button> <input type="file" id="imageInput" accept="image/*" required=""> <button onclick="uploadImage()" id="upload-image-btn">Submit Image</button>
<br><br> <br><br>
<a href="/YOUR_IMAGE.jpg" download="YOUR_IMAGE.jpg" class="download-button">
Download Sample
</a>
<div id="editable-classes"></div> <div id="editable-classes"></div>
<button id="add-class-btn">Add Class</button> <button id="add-class-btn">Add Ingredient</button>
<div id="suggested-classes"></div> <div id="suggested-classes"></div>
<br> <br>
<button onclick="generateIngredients()">Generate Ingredients</button> <button onclick="generateIngredients()">Generate Recipes</button>
<script src="/script.js"></script> <script src="/script.js"></script>
</body> </body>
</html> </html>