Code Monkey home page Code Monkey logo

fullstack-coding-challenge's Introduction

Unbabel Fullstack Challenge

A translation web app based on the Unbabel API with the following functionallity

  1. Flask backend to perform translations using the Unbabel API
  2. Web app with an input field that takes an English (EN) input translates it to Spanish (ES).
  3. List the performed translations with their state
  4. The list is ordered by the size of the translated messages

Install

Requirements

In order to run it is necessary to have Python 3. It is recomended to use a virtual environment to manage the packages used in the application.

Create a virtual environment and use it:

$ python3 -m venv venv
$ source venv/bin/activate

Or on Windows cmd:

$ py -3 -m venv venv
$ venv\Scripts\activate.bat

Install the required packages:

$ pip install -r requirements.txt

Define the environment variables:

$ export FLASK_APP=flaskr
$ export FLASK_ENV=development

Or on Windows cmd:

set FLASK_APP=flaskr
set FLASK_ENV=development
flask run

Initialize the database:

$ flask init-db

Configuration

In order for the backend to work it is necessary to have a configuration file. It should be created one file named config.py under the flaskr directory.

The file should contain values for the Unbabel user and it's key, it can also be provided an database url. The database url is composed of the scheme, connection details and the database name.

An example of an possible configuration file is:

API_USERNAME='api_username'
API_KEY='api_key'
TEST_API=True

DATABASE='postgresql://postgres_user:postgres_passwd@localhost:5432/postgres_database'
SECRET_KEY='A secret key'

Note If no database url is provided a default sqlite database will be used.

Web application

The web application source files are under the client folder.

Note In order to create a build for the application it is necessary to have node installed.

Enter the client folder and install the node packages

cd client
npm install

After that is possible to build the application with

npm run build

This will produce a build ready for production of the web application under the folder www

Run

Launch a built-in Flask development server:

$ flask run

After launch it is possible to open a browser page with the address 127.0.0.1:5000.

The build files of the web application are served under the www folder in root / endpoint and the api at the /api endpoint.

The Flask's built-in server is not suitable for production, refer to the documentation for further info.

Development

It is possible to launch a development version of the web application with the following command under the client directory

npm run dev

This will start a development server under the address http://127.0.0.1:8080

Note It is necessary to have the flask backend running to successfully use the web application.

Test

Start the tests with:

$ python -m pytest

Run tests with coverage report:

$ coverage run -m pytest
$ coverage report
$ coverage html  # open htmlcov/index.html in a browser

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.