ํ์ต๋ ML ๋ชจ๋ธ์ Flask ์น์์ ์๋น์คํ๊ธฐ
- Logistic Regression ํ๊ท๋ชจ๋ธ ์์ฑ ๋ฐ ํ์ต
- Pickle์ ์ฌ์ฉํ ๋ชจ๋ธ์ ํ์ผ ์ ์ฅ
- Flask ์น์์ ๋ชจ๋ธ์ ๋ก๋ํ์ฌ ์๋น์คํ๊ธฐ
Flask์์ ๋ฐ์ดํฐ ๋ฒ ์ด์ค ๋ค๋ฃจ๊ธฐ
- Java(Spring)์์ Flask์ JSON๋ฌธ์์ด ์ ๋ฌํ๊ณ ๋ฐ๊ธฐ
- SQLAlchemy(Flask module) CRUD(Oracle)
์ ์ -->ํผ--> ์๋ฐ -->json(json์ฌํ ์ด์ฉ, ํฌ์คํธ ๋ฐฉ์์ผ๋ก ๋ณด๋ด๊ธฐ)--> ํ๋ผ์คํฌ(request.get_json ๊ฐ์ฒด๋ฅผ ์จ์ ๋์ด์จ json๋ฌธ์์ด ๋ฐ๊ธฐ)
Flask -->์๋ฐ๋ก json ๋ฌธ์์ด์ ๋ณด๋ผ๋ jsonify ์จ์ ๋ณด๋ธ๋ค.
์คํ ๊ฒฐ๊ณผ :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import org.json.simple.JSONObject;
public class Main
{
public static void main(String[] args)
{
URL url;
try {
url = new URL("http://localhost:7777/read/14");
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("POST"); // POST ๋ฐฉ์ ์์ฒญ
//connection.setRequestProperty("User-Agent", USER_AGENT);
connection.setRequestProperty("Content-Type", "application/json");
connection.setDoOutput(true);
JSONObject jsobj = new JSONObject();
jsobj.put("id", 14);
jsobj.put("title", "Hello~");
jsobj.put("content", "Good morning everyone!");
OutputStream os = connection.getOutputStream();
os.write(jsobj.toJSONString().getBytes());
os.flush();
os.close();
int responseCode = connection.getResponseCode();
System.out.println("Book ์ถ๊ฐ ๊ฒฐ๊ณผ(์๋ต์ฝ๋):" + responseCode);
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
StringBuffer stringBuffer = new StringBuffer();
String inputLine;
while ((inputLine = bufferedReader.readLine()) != null) {
stringBuffer.append(inputLine);
}
bufferedReader.close();
String response = stringBuffer.toString();
System.out.println(response);
}catch(Exception ex) {
ex.printStackTrace();
}
}
}
|
cs |
์คํ๊ฒฐ๊ณผ :
'Framework > Flask Framework' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
(23.03.02.) Flask ํ๋ก๊ทธ๋๋ฐ: ํ๋ผ์คํฌ ์น ์๋น์ค (GET,POST) (0) | 2023.03.06 |
---|
๋๊ธ