itissid/vxy_coding_challenge
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
## Installation 0. Make a virtual env and activate it. 1. Install the python dependencies from requirements.txt ```pip install -r requirements.txt``` 2. Install bower. See https://bower.io/ 3. Install the requisite bower components from `bower.json` using `bower install` 4. Run the flask server using gunicorn ```gunicorn --workers 3 --bind 0.0.0.0:4999 app:wordcount``` 4.1 To run only on local server to debug and develop: ``` >> export FLASK_DEBUG=1 >> export FLASK_APP=app:wordcount >> flask run * Environment: production WARNING: Do not use the development server in a production environment. Use a production WSGI server instead. * Debug mode: on * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit) * Restarting with stat * Debugger is active! * Debugger PIN: 313-665-416 ``` ## Run tests From the `pwd` set to the root dir. Say `py.test voxy/` to discover and run tests in the `voxy/` module. Running py.test alone will likely not work because it tries discovering all the tests in the PWD and if you have a virtual env it can throw it off. Don't use local server in prod. The advantage of the above is a webapp that reloads with changes. Makes dev faster. There is one test I wrote to make sure things work correctly. Run it using `pytest` ## TODOs - Add some logic to avoid DDOS'ing the form with too much data. Like word count limit. # Submissions per second etc. - For `config.py` I would want to add some production keys as part of the deployment instead of hardcoding - Productionize using something like `upstart`: Ubuntu and other distributions has a nice feature to say `sudo start myapp` this would be pretty useful to run the app in production and restart things automatically on server restarts. - Logging: Did not use a logger, would be nice to catch the errors log em and send alerts. - Integration Testing: Lots of stuff here, testing application routes, running the application in a container and running a submit via some BDD server etc. - I would like to use `tox` instead of virtual env to make the environment more configurable like prod, staging, dev etc. - Internationalization: How to deal with foreign languages is a feature I would have like to build. Currently I just use NLTK to split the text and get the count. I suspect that some foreign languages treat boundaries differently, and so dealing with that would be nice. Minor things - Refactor the template into a base.html and index.html - write a script in python to run the app more easly that to fiddle with environment variables. References [1 Flask Docs](http://flask.pocoo.org/docs/0.12) [2 Understanding Application and Request Contexts](http://kronosapiens.github.io/blog/2014/08/14/understanding-contexts-in-flask.html)
About
A toy app for a coding challenge that does word counts
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published