Notice
Recent Posts
Recent Comments
Link
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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 |
Tags
- append()
- pandas
- string
- insert()
- numpy
- sklearn
- DataAccess
- Dictionary
- data
- IN
- 최솟값
- 반복문
- Python
- 분류 결과표
- count()
- dendrogram
- 최댓값
- analizer
- elbow method
- del
- Machine Learning
- matplotlib
- 덴드로그램
- wcss
- list
- nan
- DataFrame
- len()
- hierarchical_clustering
- function
Archives
- Today
- Total
개발공부
네이버 파파고 API 사용법 본문
1. Aplication 등록하기
아래 링크로 들어가 로그인한다.
애플리케이션 - NAVER Developers
developers.naver.com
Application 등록을 누른다.

3. 본인 상황에 맞게 입력한다.

4. 생성된 client id와 secret을 사용해 API 사용이 가능하다.

# 한국어를 중국어로 번역하는 예제
config.py
class Config :
JWT_SECRET_KEY = 'YOUR_SECREY_KEY'
JWT_ACCESS_TOKEN_EXPIRES = False
PROPAGATE_EXCEPTIONS = True
NAVER_PAPAGO_URL = 'https://openapi.naver.com/v1/papago/n2mt'
NAVER_CLIENT_ID = 'YOUR_CLIENT_ID'
NAVER_CLIENT_SECRET = 'YOUR_CLIENT_SECRET'
app.py
from flask import Flask
from flask_restful import Api
from config import Config
from resources.naver import NaverPapagoResource
app = Flask(__name__)
# 환경변수 셋팅
app.config.from_object(Config)
api = Api(app)
api.add_resource(NaverPapagoResource, '/chinese')
if __name__ == '__main__' :
app.run()
resources/naver.py
from flask import request
from flask_restful import Resource
import requests
from config import Config
class NaverPapagoResource(Resource) :
def get(self) :
text = request.args.get('text')
hearders = {'Content-Type' : 'application/x-www-form-urlencoded; charset=UTF-8',
'X-Naver-Client-Id' : Config.NAVER_CLIENT_ID,
'X-Naver-Client-Secret' : Config.NAVER_CLIENT_SECRET}
data = {'source' : 'ko',
'target' : 'zh-CN',
'text' : text}
res = requests.post(Config.NAVER_PAPAGO_URL, data, headers = hearders)
translatedText = res.json()['message']['result']['translatedText']
return {'result' : translatedText}
Postman

'Python > Flask' 카테고리의 다른 글
| Serverless Framework를 이용해 AWS에 배포 자동화 (Github 연결) CI/CD (0) | 2022.06.29 |
|---|---|
| AWS Lambda를 이용한 Serverless Applications (0) | 2022.06.28 |
| boto3로 이미지 인식하는 Rekognition 사용법 (0) | 2022.06.27 |
| boto3로 S3 파일 업로드 (0) | 2022.06.24 |
| [Flask 에서 JWT 사용] Logout 기능 구현 (0) | 2022.06.21 |