Giter Site home page Giter Site logo

jsun-m / django-serverless Goto Github PK

View Code? Open in Web Editor NEW

This project forked from smartshare-labs/django-serverless

0.0 0.0 0.0 51 KB

The fastest way to develop and deploy Django APIs with Serverless.

Python 96.86% Makefile 2.02% Dockerfile 0.46% Shell 0.66%

django-serverless's Introduction

Django-Serverless Template

Designed for rapid development of serverless APIs.

Pre-requisites

Usage

  • Get setup: make init

  • Run local API (binds to localhost:5000): make start

  • Reset local database (completely): make reset

  • Dump local database (data not structure): make flush

  • Dump production database (data not structure): make flush-live

  • Generate new migrations after changing a model: make migrations

  • Running migrations locally: make migrate

  • Running migrations in production: make migrate-live

  • Deploy to lambda in dev: make deploy-dev

  • Deploy to lambda in prod: make deploy-prod

Quickstart: creating an API

  1. Create a new folder in functions with the name of your endpoint.
  2. Add the new endpoint and HTTP method to serverless.yaml.
  3. Update ./sls_django/settings.py with the name of your new endpoint.
  4. Write your business logic to a file in the ./logic directory.
  5. If creating a new model, duplicate one of the existing folders in sls_django, and rename with the name of your Entity.
  6. Add Models or Serializers accordingly.
  7. If you made changes to a model, run make migrations followed by make migrate. Then, you're ready to run your endpoint locally. Restart your local server, running make start.
  8. Enjoy your endpoint, and proceed to develop subsequent APIs faster than ever.

Running endpoint code directly

Run python -m functions.functionName.handler

Testing (WIP)

Write your tests in the ./tests folder. Then:

  1. Create a virtual environment in ./tests: virtualenv -p python3 venv
  2. Source it: source venv/bin/activate
  3. Install requirements: pip install -U requirements.txt

Finally, to run tests: python -m pytest tests from the root directory.

django-serverless's People

Contributors

luke-lombardi avatar jsun-m avatar mernit 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.