Coder Social home page Coder Social logo

scurri_exercise_2's Introduction

Scurri Exercise #2

Write a library that supports validating and formatting postcodes for the UK.

The details of which postcodes are valid and which are the parts they consist of can be found at https://en.wikipedia.org/wiki/Postcodes_in_the_United_Kingdom#Formatting.

The API that this library provides is your choice.

Please make sure you write the library yourself and the API is then to use the library that you created. Ensure there are functions in order to format. Show all tests written so our engineer can see your thought process.

  • python3 -m pip install --upgrade pip
  • python3 -m venv env(PS> virtualenv env)
  • source env/bin/activate (PS> .\env\Scripts\activate.bat)
  • pip3 install -r requirements.txt
  • export FLASK_ENV=development
  • export set FLASK_APP=app.webapp (PS> $env:FLASK_APP="webapp")
  • python3 -m flask run --host=0.0.0.0 (PS> flask run)

How to call the app locally

Postman is the better option since it doesn't replace the "space" by "%20"

alt text

But you can also test using any browser in these two endpoint:

http://localhost:5000/verify_postcode?postcode=BB10 2BF

alt text

or

http://localhost:5000/postcodes/BB10%202BF

alt text

Tests

  • coverage run -m pytest
  • coverage report -m

There is a massive test called test_massive_validation runs against 50.000 postcodes (csv files from https://www.ordnancesurvey.co.uk/business-and-government/products/code-point-open.html) and takes a long time to run (8 minutes). Please uncomment lines 137-140 in the file scurri_exercise_2/app/tests/test_exercise_2.py if you wish to run that test.

Heroku Deploy

https://scurri-exercise-2-app.herokuapp.com/verify_postcode?postcode=BB10%202AL

https://scurri-exercise-2-app.herokuapp.com/postcodes/BB10%202BF

  • heroku login
  • heroku create scurri-exercise-2-app
  • git push heroku master / git push heroku HEAD:master
  • heroku config:set SECRET_KEY=scurri_892840328239048
  • heroku logs --tail

scurri_exercise_2's People

Contributors

rogeriosantosluz avatar

Stargazers

 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.