Skip to content

Commit

Permalink
Merge pull request #6 from 9JIIIIIN9/main
Browse files Browse the repository at this point in the history
my-replicate-app에 host 제거
hyunjin1109 authored Jun 8, 2024
2 parents b763a23 + 9f4aef3 commit 681494c
Showing 6 changed files with 172 additions and 43 deletions.
20 changes: 12 additions & 8 deletions my-replicate-app/index.js
Original file line number Diff line number Diff line change
@@ -15,7 +15,8 @@ import path from "path";
dotenv.config();

const REPLICATE_API_TOKEN = process.env.REPLICATE_API_TOKEN;
const JWT2 = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySW5mb3JtYXRpb24iOnsiaWQiOiI3NWQxNDhiNS1kMzQ5LTRlZmUtYTcwYy04YjA2NmIwYWVlYjciLCJlbWFpbCI6InJ5bHlubjEwMjlAbmF2ZXIuY29tIiwiZW1haWxfdmVyaWZpZWQiOnRydWUsInBpbl9wb2xpY3kiOnsicmVnaW9ucyI6W3siaWQiOiJGUkExIiwiZGVzaXJlZFJlcGxpY2F0aW9uQ291bnQiOjF9LHsiaWQiOiJOWUMxIiwiZGVzaXJlZFJlcGxpY2F0aW9uQ291bnQiOjF9XSwidmVyc2lvbiI6MX0sIm1mYV9lbmFibGVkIjpmYWxzZSwic3RhdHVzIjoiQUNUSVZFIn0sImF1dGhlbnRpY2F0aW9uVHlwZSI6InNjb3BlZEtleSIsInNjb3BlZEtleUtleSI6IjFlNjIwM2Q0NjIzY2I3ZTBlODFkIiwic2NvcGVkS2V5U2VjcmV0IjoiZjczNDVlNDIxZjkzNjNkNjJiYzU3ZWQ5ZTBlY2Y5NzQ5YzEzMjRhM2Q1YjE1ZmQwY2U4MTk4ZDU5ZTBmM2NiMSIsImlhdCI6MTcxMTA4Mzg5M30.ofdRllbxJO2Qk0-co3FXaPpou6EBRqE9gImfu6iR06Q"; // Replace with your actual JWT token
const JWT2 =
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySW5mb3JtYXRpb24iOnsiaWQiOiI3NWQxNDhiNS1kMzQ5LTRlZmUtYTcwYy04YjA2NmIwYWVlYjciLCJlbWFpbCI6InJ5bHlubjEwMjlAbmF2ZXIuY29tIiwiZW1haWxfdmVyaWZpZWQiOnRydWUsInBpbl9wb2xpY3kiOnsicmVnaW9ucyI6W3siaWQiOiJGUkExIiwiZGVzaXJlZFJlcGxpY2F0aW9uQ291bnQiOjF9LHsiaWQiOiJOWUMxIiwiZGVzaXJlZFJlcGxpY2F0aW9uQ291bnQiOjF9XSwidmVyc2lvbiI6MX0sIm1mYV9lbmFibGVkIjpmYWxzZSwic3RhdHVzIjoiQUNUSVZFIn0sImF1dGhlbnRpY2F0aW9uVHlwZSI6InNjb3BlZEtleSIsInNjb3BlZEtleUtleSI6IjFlNjIwM2Q0NjIzY2I3ZTBlODFkIiwic2NvcGVkS2V5U2VjcmV0IjoiZjczNDVlNDIxZjkzNjNkNjJiYzU3ZWQ5ZTBlY2Y5NzQ5YzEzMjRhM2Q1YjE1ZmQwY2U4MTk4ZDU5ZTBmM2NiMSIsImlhdCI6MTcxMTA4Mzg5M30.ofdRllbxJO2Qk0-co3FXaPpou6EBRqE9gImfu6iR06Q"; // Replace with your actual JWT token

const PORT = process.env.PORT || 5002;
const pipeline = promisify(stream.pipeline);
@@ -28,17 +29,20 @@ app.use(bodyParser.json());

app.use(
cors({
origin: ['http://localhost:3000', 'http://localhost:8888', 'https://spirographmaker.netlify.app'],
methods: 'GET,HEAD,PUT,PATCH,POST,DELETE',
origin: [
"http://localhost:3000",
"http://localhost:8888",
"https://spirographmaker.netlify.app",
],
methods: "GET,HEAD,PUT,PATCH,POST,DELETE",
credentials: true,
allowedHeaders: 'Content-Type, Authorization',
allowedHeaders: "Content-Type, Authorization",
})
);

const urlStatus = {};

async function pinFileToIPFS(filePath) {

const proxyUrl = "https://frozen-scrubland-19711-6243810201c8.herokuapp.com/";
const targetUrl = "https://api.pinata.cloud/pinning/pinFileToIPFS";
const url = `${proxyUrl}${targetUrl}`;
@@ -63,7 +67,6 @@ async function pinFileToIPFS(filePath) {
}

const pinJSONToIPFS = async (json) => {

const proxyUrl = "https://frozen-scrubland-19711-6243810201c8.herokuapp.com/";
const targetUrl = "https://api.pinata.cloud/pinning/pinFileToIPFS";
const url = `${proxyUrl}${targetUrl}`;
@@ -98,7 +101,8 @@ async function runReplicateModel(url, prompt) {
auth: REPLICATE_API_TOKEN,
});

const model = "stability-ai/sdxl:39ed52f2a78e934b3ba6e2a89f5b1c712de7dfea535525255b1aa35c5565e08b";
const model =
"stability-ai/sdxl:39ed52f2a78e934b3ba6e2a89f5b1c712de7dfea535525255b1aa35c5565e08b";
const input = {
width: 768,
height: 768,
@@ -234,6 +238,6 @@ app.get("/check-status", (req, res) => {
res.json(statusInfo);
});

app.listen(PORT, host, () => {
app.listen(PORT, () => {
console.log(`Server running at http://localhost:${PORT}`);
});
3 changes: 3 additions & 0 deletions spirograph/build/static/js/main.1ededde9.js

Large diffs are not rendered by default.

94 changes: 94 additions & 0 deletions spirograph/build/static/js/main.1ededde9.js.LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
/*!
* GSAP 3.12.5
* https://gsap.com
*
* @license Copyright 2008-2024, GreenSock. All rights reserved.
* Subject to the terms at https://gsap.com/standard-license or for
* Club GSAP members, the agreement issued with that membership.
* @author: Jack Doyle, jack@greensock.com
*/

/*! p5.js v1.9.0 November 28, 2023 */

/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */

/**
* @license React
* react-dom.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

/**
* @license React
* react-jsx-runtime.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

/**
* @license React
* react.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

/**
* @license React
* scheduler.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

/**
* @license React
* use-sync-external-store-shim.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

/**
* @remix-run/router v1.15.3
*
* Copyright (c) Remix Software Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE.md file in the root directory of this source tree.
*
* @license MIT
*/

/**
* React Router v6.22.3
*
* Copyright (c) Remix Software Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE.md file in the root directory of this source tree.
*
* @license MIT
*/

/**
* [js-sha3]{@link https://github.com/emn178/js-sha3}
*
* @version 0.8.0
* @author Chen, Yi-Cyuan [emn178@gmail.com]
* @copyright Chen, Yi-Cyuan 2015-2018
* @license MIT
*/
1 change: 1 addition & 0 deletions spirograph/build/static/js/main.1ededde9.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion spirograph/netlify.toml
Original file line number Diff line number Diff line change
@@ -17,4 +17,4 @@
[headers.values]
Access-Control-Allow-Origin = "*"
Access-Control-Allow-Methods = "GET, POST, PUT, DELETE, OPTIONS"
Access-Control-Allow-Headers = "Content-Type, Authorization"
Access-Control-Allow-Headers = "Content-Type, Authorization"
95 changes: 61 additions & 34 deletions spirograph/src/components/Sketch/Sketch.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useEffect, useRef, useState, useCallback } from 'react';
import p5 from 'p5';
import { useNavigate } from 'react-router-dom';
import React, { useEffect, useRef, useState, useCallback } from "react";
import p5 from "p5";
import { useNavigate } from "react-router-dom";
// import { useConnectWallet } from 'use-wallet';
// import { ethers } from 'ethers';
// import abi from './abi'; // Assuming abi.js is exported from this path
@@ -62,7 +62,7 @@ const Sketch = ({
// } catch (error) {
// console.error("Error:", error);
// }
// }
// }

// useRef를 사용하여 참조 유지
const firstNameRef = useRef(firstName);
@@ -71,12 +71,9 @@ const Sketch = ({
const handleProgressRef = useRef(onProgress);
const handleEndRef = useRef(onEnd);

const handleProgress = useCallback(
(progress) => {
handleProgressRef.current(progress);
},
[]
);
const handleProgress = useCallback((progress) => {
handleProgressRef.current(progress);
}, []);

const handleEnd = useCallback(() => {
handleEndRef.current();
@@ -119,8 +116,22 @@ const Sketch = ({

p.draw = () => {
p.translate(p.width / 2, p.height / 2);
drawSpirograph(p, R, r, currentRotation, getRandomColor(p), firstNameRef.current);
drawSpirograph(p, R2, r2, currentRotation, getRandomColor(p), firstNameRef.current);
drawSpirograph(
p,
R,
r,
currentRotation,
getRandomColor(p),
firstNameRef.current
);
drawSpirograph(
p,
R2,
r2,
currentRotation,
getRandomColor(p),
firstNameRef.current
);
currentRotation += baseAngleIncrement;

const progressPercentage = Math.min(
@@ -143,23 +154,22 @@ const Sketch = ({
const formData = new FormData();
formData.append("image", blob);

const proxyUrl = "https://frozen-scrubland-19711-6243810201c8.herokuapp.com/"
const targeturl = "https://calm-eyrie-10609-82f65a8348a1.herokuapp.com/upload-to-ipfs";
const proxyUrl =
"https://frozen-scrubland-19711-6243810201c8.herokuapp.com/";
const targeturl =
"https://calm-eyrie-10609-82f65a8348a1.herokuapp.com/upload-to-ipfs";
const url = `${proxyUrl}${targeturl}`;
try {
const response = await fetch(
url,
{
method: "POST",
body: formData, // FormData 객체 전송
headers: {
'Accept': 'application/json',
'Content-Type': 'application/x-www-form-urlencoded',
// 추가 헤더가 필요한 경우 여기에 추가
},
credentials: 'include', // 이 설정을 추가하여 쿠키를 포함합니다
}
);
const response = await fetch(url, {
method: "POST",
body: formData, // FormData 객체 전송
headers: {
Accept: "application/json",
"Content-Type": "application/x-www-form-urlencoded",
// 추가 헤더가 필요한 경우 여기에 추가
},
credentials: "include", // 이 설정을 추가하여 쿠키를 포함합니다
});
const data = await response.json();
console.log(data.ipfsUrl, "clientside");
setUrl(data.ipfsUrl);
@@ -183,16 +193,28 @@ const Sketch = ({
y = (R / r) * p.sin(angle) - (r - R) * p.sin(angle * (R - r));
break;
case "이":
x = (R - r) * p.cos(angle) + r * p.cos((angle * (R - r)) / r + p.PI / 4);
y = (R - r) * p.sin(angle) - r * p.sin((angle * (R - r)) / r + p.PI / 4);
x =
(R - r) * p.cos(angle) +
r * p.cos((angle * (R - r)) / r + p.PI / 4);
y =
(R - r) * p.sin(angle) -
r * p.sin((angle * (R - r)) / r + p.PI / 4);
break;
case "박":
x = (R - r) * p.cos(angle) + r * p.cos((angle * (R - r)) / r - p.PI / 4);
y = (R - r) * p.sin(angle) - r * p.sin((angle * (R - r)) / r - p.PI / 4);
x =
(R - r) * p.cos(angle) +
r * p.cos((angle * (R - r)) / r - p.PI / 4);
y =
(R - r) * p.sin(angle) -
r * p.sin((angle * (R - r)) / r - p.PI / 4);
break;
case "최":
x = (R - r) * p.cos(angle) + r * p.cos((angle * (R - r)) / r + p.PI / 2);
y = (R - r) * p.sin(angle) - r * p.sin((angle * (R - r)) / r + p.PI / 2);
x =
(R - r) * p.cos(angle) +
r * p.cos((angle * (R - r)) / r + p.PI / 2);
y =
(R - r) * p.sin(angle) -
r * p.sin((angle * (R - r)) / r + p.PI / 2);
break;
default:
x = (R - r) * p.cos(angle) + r * p.cos((angle * (R - r)) / r);
@@ -218,7 +240,12 @@ const Sketch = ({
let hash = 0x811c9dc5;
for (let i = 0; i < str.length; i++) {
hash ^= str.charCodeAt(i);
hash += (hash << 1) + (hash << 4) + (hash << 7) + (hash << 8) + (hash << 24);
hash +=
(hash << 1) +
(hash << 4) +
(hash << 7) +
(hash << 8) +
(hash << 24);
}
return hash >>> 0;
};

0 comments on commit 681494c

Please sign in to comment.