-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'jeongmin' of https://github.com/skkuse/2024spring_41cla…
…ss_team5 into jeongmin
- Loading branch information
Showing
2 changed files
with
70 additions
and
26 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,34 @@ | ||
from fastapi import APIRouter | ||
from green_function import * | ||
#import pymysql | ||
from database import create_session | ||
|
||
import pymysql | ||
import subprocess | ||
import os | ||
import time | ||
|
||
green_router = APIRouter( | ||
tags=["Green"], | ||
) | ||
|
||
|
||
# conn = pymysql.connect(host = 'localhost', user='wonyeong', password = 'your_password', db = 'sample', charset = 'utf8') | ||
# cur = conn.cursor() | ||
|
||
conn, cur = create_session() | ||
conn = pymysql.connect(host = 'localhost', user='wonyeong', password = 'your_password', db = 'backend', charset = 'utf8') | ||
cur = conn.cursor() | ||
|
||
|
||
@green_router.post("/") | ||
async def get_green(request: RequestModel): | ||
response = get_LLM_response(request.data) | ||
return {response} | ||
|
||
@green_router.post("/save") | ||
async def get_data(request: FixedCode): | ||
# @green_router.post("/save") | ||
# async def get_data(request: FixedCode): | ||
|
||
# code = request.fixed_code | ||
# user_id = request.id | ||
# sql = "INSERT INTO codes (user_id, code) VALUES (%s, %s)" | ||
# cur.execute(sql, (user_id, code)) | ||
# conn.commit() | ||
# return {"message": "Data saved successfully"} | ||
|
||
code = request.fixed_code | ||
user_id = request.id | ||
sql = "INSERT INTO codes (user_id, code) VALUES (%s, %s)" | ||
cur.execute(sql, (user_id, code)) | ||
conn.commit() | ||
return {"message": "Data saved successfully"} | ||
|
||
|
||
|
||
''' | ||
TABLE `codes` ( | ||
`code_id` INT NOT NULL AUTO_INCREMENT, | ||
`user_id` CHAR(10) NOT NULL, | ||
`code` VARCHAR(1000) NOT NULL, | ||
`date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
PRIMARY KEY (`code_id`, `user_id`) | ||
); | ||
''' | ||
|