Coder Social home page Coder Social logo

kurt213 / hanzi-pinyin-api Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 32 KB

Create a personal REST API to translate Hanzi Chinese characters to Pinyin

License: GNU General Public License v3.0

Python 100.00%
api-rest hanzi hanzi-characters hanzi-pinyin hanzi2pinyin mandarin mandarin-chinese pinyin translation translator

hanzi-pinyin-api's Introduction

hanzi-pinyin-api

Create a personal REST API to translate Hanzi Chinese characters to Pinyin

About

This is a simple REST API that translates Hanzi Chinese characters to Pinyin. It uses the following two sources:

Installation

  1. Clone this repository
  2. Install the requirements: pip install -r requirements.txt
  3. Create a .env file in the root directory and add the following variables:
APP_API_KEY_1=<your-api-key>:<user_alias>
APP_API_KEY_2=<your-api-key>:<user_alias>
DEEPL_API_KEY=<your-deepl-api-key>
  • replace <your-api-key> with a secure random string of your choice. This will be used to authenticate requests to the API.
  • Note: <user_alias> can be any string and can be used as an identifier of who is calling your API when looking at the API logs. e.g. 2lkmglk23m:sam
  • APP_API_KEY_2 and upwards can be used to add additional API keys. You can add as many as you like.
  • replace <your-deepl-api-key> with your created API key from DeepL.
  1. Run the app: python main.py
  2. The app will run by default on http://127.0.0.1:8000

Usage

When you run the app, you can access the API at http://127.0.0.1:8000/.

You will also need to set the request header acces_token to the value of the APP_API_KEY variable you set in the .env file.

The API has two endpoints:

  • / - returns hello world
  • /hanzi/:hanzi-string - translates a Hanzi string to Pinyin

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.