Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions webapp/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@
const express = require('express');
const fs = require('fs');
const https = require('https');
const path = require('path');
const app = express();

// Serves your css as static.
app.use(express.static(__dirname));
app.use((req, res, next) => { if (req.path === '/server.js') return res.status(404).send('Not found'); next(); });
app.use(express.static(__dirname, { index: false }));

// Increases data limit.
app.use(express.json({limit: '50mb'}));
Expand Down Expand Up @@ -56,7 +58,7 @@ app.post('/imageCaption', async (req, res) => {

// Gets replicate image caption BLIP2.
async function replicateGenerateCaption(image, caption, question) {
const apikey = 'YOUR API KEY';
const apikey = process.env.REPLICATE_TOKEN || '';
const endpoint = 'https://api.replicate.com/v1/predictions';

const response = await fetch(endpoint, {
Expand All @@ -78,7 +80,7 @@ async function replicateGenerateCaption(image, caption, question) {

// Gets finalized replicate image caption BLIP2.
async function replicateGetCaption(id) {
const apikey = 'YOUR API KEY';
const apikey = process.env.REPLICATE_TOKEN || '';
const endpoint = `https://api.replicate.com/v1/predictions/${id}`;

const response = await fetch(endpoint, {
Expand Down