Initial commit
This commit is contained in:
2
src/common/const.py
Executable file
2
src/common/const.py
Executable file
@@ -0,0 +1,2 @@
|
||||
# WEB SERVER PORT
|
||||
SERVICE_PORT = 51001
|
||||
65
src/static/css/style.css
Executable file
65
src/static/css/style.css
Executable file
@@ -0,0 +1,65 @@
|
||||
body {
|
||||
font-family: sans-serif;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
background: linear-gradient(135deg, #ece9e6, #ffffff);
|
||||
color: #444;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
height: 100vh;
|
||||
}
|
||||
|
||||
.title_zone {
|
||||
margin-bottom: 25px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.title {
|
||||
font-size: 36px;
|
||||
font-weight: bold;
|
||||
color: #323232;
|
||||
text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
.img_generator_model_zone_1, .img_generator_model_zone_2 {
|
||||
background-color: #ffffff;
|
||||
border: 1px solid #e0e0e0;
|
||||
border-radius: 10px;
|
||||
padding: 25px;
|
||||
margin: 30px;
|
||||
box-shadow: 0 3px 8px rgba(0, 0, 0, 0.15);
|
||||
width: 35%;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.model_name {
|
||||
font-size: 20px;
|
||||
margin-bottom: 15px;
|
||||
color: #555;
|
||||
}
|
||||
|
||||
.input_txt_box {
|
||||
width: calc(100% - 20px);
|
||||
padding: 12px;
|
||||
margin-bottom: 20px;
|
||||
border: 1px solid #ccc;
|
||||
border-radius: 5px;
|
||||
font-size: 14px;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.generator_btn_zone {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.generator_btn {
|
||||
background-color: #646464;
|
||||
color: #fff;
|
||||
border: none;
|
||||
padding: 10px 25px;
|
||||
font-size: 15px;
|
||||
border-radius: 5px;
|
||||
cursor: pointer;
|
||||
}
|
||||
33
src/static/js/api.js
Executable file
33
src/static/js/api.js
Executable file
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
@File: api.js
|
||||
@Date: 2025-01-16
|
||||
@author: DaoolDNS
|
||||
@brief: AI 이미지 생성 웹 서버
|
||||
@section MODIFYINFO 수정정보
|
||||
- 수정자/수정일 : 수정내역
|
||||
- 2025-01-16/ksy : base
|
||||
*/
|
||||
|
||||
//post data func
|
||||
function postData(url = '', data = {}) {
|
||||
return fetch(url, {
|
||||
method: 'POST', // *GET, POST, PUT, DELETE, etc.
|
||||
mode: 'cors', // no-cors, cors, *same-origin
|
||||
cache: 'no-cache', // *default, no-cache, reload, force-cache, only-if-cached
|
||||
credentials: 'same-origin', // include, *same-origin, omit
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
// 'Content-Type': 'application/x-www-form-urlencoded',
|
||||
},
|
||||
redirect: 'follow', // manual, *follow, error
|
||||
referrer: 'no-referrer', // no-referrer, *client
|
||||
body: JSON.stringify(data), // body data type must match "Content-Type" header
|
||||
})
|
||||
.then((response) => {
|
||||
if(response.status == 422) {
|
||||
throw new Error('Unprocessable Entity(Code: 422)')
|
||||
}
|
||||
return response.json()
|
||||
})
|
||||
.catch(error => console.error(error)) // parses JSON response into native JavaScript objects
|
||||
}
|
||||
17
src/static/js/config.js
Executable file
17
src/static/js/config.js
Executable file
@@ -0,0 +1,17 @@
|
||||
/*
|
||||
@File: config.js
|
||||
@Date: 2025-01-16
|
||||
@author: A2TEC
|
||||
@brief: G 웹 서버
|
||||
@section MODIFYINFO 수정정보
|
||||
- 수정자/수정일 : 수정내역
|
||||
- 2025-01-16/ksy : base
|
||||
*/
|
||||
|
||||
const REST_SERVER = {
|
||||
IP: "192.168.200.230",
|
||||
PORT: 51000
|
||||
}
|
||||
|
||||
const DALLE3_REQUEST_URL = "/api/services/imageGenerate/dalle3"
|
||||
const IMAGEN_REQUEST_URL = "/api/services/imageGenerate/imagen"
|
||||
12
src/static/js/const.js
Executable file
12
src/static/js/const.js
Executable file
@@ -0,0 +1,12 @@
|
||||
/*
|
||||
@File: const.js
|
||||
@Date: 2025-01-16
|
||||
@author: A2TEC
|
||||
@brief: G 웹 서버
|
||||
@section MODIFYINFO 수정정보
|
||||
- 수정자/수정일 : 수정내역
|
||||
- 2025-01-16/ksy : base
|
||||
*/
|
||||
|
||||
const inputTxtBox1 = $('#input_txt_box_1')
|
||||
const inputTxtBox2 = $('#input_txt_box_2')
|
||||
4
src/static/js/jquery.min.js
vendored
Executable file
4
src/static/js/jquery.min.js
vendored
Executable file
File diff suppressed because one or more lines are too long
35
src/static/js/utility.js
Executable file
35
src/static/js/utility.js
Executable file
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
@File: utility.js
|
||||
@Date: 2025-01-16
|
||||
@author: DaoolDNS
|
||||
@brief: AI 이미지 생성 웹 서버
|
||||
@section MODIFYINFO 수정정보
|
||||
- 수정자/수정일 : 수정내역
|
||||
- 2025-01-16/ksy : base
|
||||
*/
|
||||
|
||||
let apiRequestBody = { "prompt": "" }
|
||||
|
||||
function generatorBtn1() {
|
||||
try {
|
||||
const apiUrl = `http://${REST_SERVER.IP}:${REST_SERVER.PORT}${DALLE3_REQUEST_URL}`
|
||||
|
||||
apiRequestBody.prompt = inputTxtBox1.val()
|
||||
postData(apiUrl, apiRequestBody)
|
||||
}
|
||||
catch (error) {
|
||||
console.error(`Error: ${error.name}`)
|
||||
}
|
||||
}
|
||||
|
||||
function generatorBtn2() {
|
||||
try {
|
||||
const apiUrl = `http://${REST_SERVER.IP}:${REST_SERVER.PORT}${IMAGEN_REQUEST_URL}`
|
||||
|
||||
apiRequestBody.prompt = inputTxtBox2.val()
|
||||
postData(apiUrl, apiRequestBody)
|
||||
}
|
||||
catch (error) {
|
||||
console.error(`Error: ${error.name}`)
|
||||
}
|
||||
}
|
||||
48
src/templates/index.html
Executable file
48
src/templates/index.html
Executable file
@@ -0,0 +1,48 @@
|
||||
<!---
|
||||
@File: index.html
|
||||
@Date: 2025-01-16
|
||||
@author: A2TEC
|
||||
@brief: G 웹 서버
|
||||
@section MODIFYINFO 수정정보
|
||||
- 수정자/수정일 : 수정내역
|
||||
- 2025-01-16/ksy : base
|
||||
-->
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<!-- <head> -->
|
||||
<meta charset="UTF-8">
|
||||
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>ImageGenerator</title>
|
||||
<script src="static/js/jquery.min.js"></script>
|
||||
<script src="static/js/config.js"></script>
|
||||
<link rel="stylesheet" href="static/css/style.css" type="text/css">
|
||||
</head>
|
||||
<body>
|
||||
<div class="title_zone">
|
||||
<span class="title">AI Image Generator</span>
|
||||
</div>
|
||||
<div class="img_generator_model_zone_1">
|
||||
<span class="model_name">DALL-E 3</span>
|
||||
<div>
|
||||
<input type="text" id="input_txt_box_1" class="input_txt_box" placeholder="입력하세요.">
|
||||
</div>
|
||||
<div class="generator_btn_zone">
|
||||
<button onclick="generatorBtn1()" id="generator_1_btn" class="generator_btn">Create</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="img_generator_model_zone_2">
|
||||
<span class="model_name">Imagen</span>
|
||||
<div>
|
||||
<input type="text" id="input_txt_box_2" class="input_txt_box" placeholder="입력하세요.">
|
||||
</div>
|
||||
<div class="generator_btn_zone">
|
||||
<button onclick="generatorBtn2()" id="generator_1_btn" class="generator_btn">Create</button>
|
||||
</div>
|
||||
</div>
|
||||
<script src="static/js/const.js"></script>
|
||||
<script src="static/js/api.js"></script>
|
||||
<script src="static/js/utility.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
37
src/web_server.py
Executable file
37
src/web_server.py
Executable file
@@ -0,0 +1,37 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
@File: web_server.py
|
||||
@Date: 2025-01-16
|
||||
@author: DaoolDNS
|
||||
@brief: AI 이미지 생성 웹 서버
|
||||
@section MODIFYINFO 수정정보
|
||||
- 수정자/수정일 : 수정내역
|
||||
- 2025-01-16/ksy : base
|
||||
"""
|
||||
|
||||
|
||||
import uvicorn
|
||||
from fastapi import FastAPI, Request
|
||||
from fastapi.responses import HTMLResponse
|
||||
from fastapi.staticfiles import StaticFiles
|
||||
from fastapi.templating import Jinja2Templates
|
||||
from common.const import SERVICE_PORT
|
||||
|
||||
app = FastAPI()
|
||||
|
||||
app.mount("/static", StaticFiles(directory="static"), name="static")
|
||||
|
||||
templates = Jinja2Templates(directory="templates")
|
||||
|
||||
@app.get("/", response_class=HTMLResponse)
|
||||
async def home(request: Request):
|
||||
"""
|
||||
메인화면 접속
|
||||
:return: index.html
|
||||
"""
|
||||
return templates.TemplateResponse("index.html", {"request": request})
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
uvicorn.run("web_server:app", host='0.0.0.0', port=SERVICE_PORT)
|
||||
Reference in New Issue
Block a user