Code Monkey home page Code Monkey logo

omninexttest's Introduction

Serverless Framework Python Flask API OmniNext Test

Implementation of Rest API for the creation and display of the user model, In particular focusing on create the following endpoints with the respective methods for writing and reading on the DB:

createUser

getUserById

Requirements

  • python3.9
  • npm
  • AWS CLI
  • serverless framework

Install

First install serverless-python-requirements and serverless-wsgi, both are already in devDependencies inside our package.json. To install them go in the project main directory using npm:

npm install

Then create a virtual environment and activate it. I'm using Python3.9 as runtime environment:

virtualenv venv --python=python3

Activate it:

source venv/bin/activate

Deploy functions:

Taking for granted that the reader has linked IAM with AWS CLI, and has already configured serverless, just run:

sls deploy

Since we're storing Users in a database we want to store them by userId, which is a unique identifier for a particular user.

I'll use curl for these examples.

Set the DOMAIN variable to your unique domain and base path so it's easier to reuse:

export DOMAIN=YOURDOMAIN

In my case:

export DOMAIN=https://n51iverkzf.execute-api.us-east-1.amazonaws.com/dev

Now let's add a new user:

curl -H "Content-Type: application/json" -X POST ${DOMAIN}/users -d '{"userId": "ID", "name": "NAME"}'

The output should be like this:

"userId": "ID",

"name": "NAME"

I've already insert some tables, you can check them using curl:

curl -H "Content-Type: application/json" -X GET ${DOMAIN}/users/keewee

Or directly in your browser:

https://n51iverkzf.execute-api.us-east-1.amazonaws.com/dev/users/keewee

omninexttest's People

Contributors

kinycx avatar

Watchers

 avatar

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.