Giter Site home page Giter Site logo

users_postalcode_register's Introduction

App for registering users through their postal code.

The objective of the project was to build an endpoint to register users and their postal codes. The city of the users can be inferred using their postal code. The endpoints needed to accept and respond in JSON format. To develop this project I used Django REST framework.

Django REST framework is a highly scalable and popular framework meant to build JSON APIs. The advantage of it being scalable is that once it is setup more endpoints can be added with relatively small effort. On the other hand, since the framework is popular it makes it easy to find support on the internet for it and it is being constantly mantained.

For any questions please contact: [email protected]

Prerequirements.

  1. Developed and tested under Python.

    $ python --version
    Python 3.9.16
  2. This project uses geonames API to lookup the cities of the users based on the postal code. There needs to be a registred user to use freely the geonames API. Follow the instructions to create a registered user from here. Specify the created username in an .env file. This file needs to be located at the same lavel as the manage.pyfile. Sample .env file:

    GEONAMES_USERNAME=geoonames_username

Installation.

  1. (Optional) Create a virtual environment.

  2. Install the package.

    $ pip install -e .

    The last command will install all the required dependencies. Including Django and Django REST framework.

  3. Once everything is installed run the Django migrations. This step will create the database and the required tables.

    $ python manage.py makemigrations
    $ python manage.py migrate

Run the server.

Django comes with a small server for testing. To run the server:

$ python manage.py runserver
Watching for file changes with StatReloader
Performing system checks...

System check identified no issues (0 silenced).
May 01, 2023 - 12:22:09
Django version 4.2, using settings 'users_postalcode_register.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.

Available endpoints.

Once the server is running the following endpoints are available.

  • GET /users/. Retrieve all the available users in the DB.
  • POST /users/. Create a new user using a JSON. Sample JSON:
    {
        "username": "sherpa.ai",
        "postal_code": "01008"
    }
    The API will respond with a status code 201 and the created object if the request was successful. Example:
    {
        "id": 1,
        "username": "sherpa.ai",
        "postal_code": "01008",
        "city": "Gasteiz / Vitoria"
    }
  • GET /users/<id>/. Retrieve a single user from the DB.

users_postalcode_register's People

Contributors

aponcedeleonch 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.