Skip to content

Example geolocation web application using the Python, MongoDB, and JQuery with Bootstrap.

License

Notifications You must be signed in to change notification settings

rbrisita/fakeFourSquare

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

fake Four Square

Example Web Application

ffs

This is an example web application written using JS with a Python backend and MongoDB data store. It finds the user's location or sets a default, then requests fake places or generates 10 new ones with fake reviews (up to 5). The user can leave reviews or get directions for a selected place. Generated data and saved reviews last for 10 minutes from creation. If places and reviews get deleted, refresh browser.

Run Locally

  1. Install MongoDB

OS X:

brew install mongodb
mkdir -p data/db
  1. Run MongoDB
mongod --fork --dbpath 'data/db' --bind_ip 127.0.0.1 --logpath '/usr/local/var/log/mongodb/mongo.log' --logappend --pidfilepath db.pid
  1. Install dependencies
pip install -r requirements.txt
mkdir logs
touch logs/app.log
  1. Get a Map Access Token

The example application uses Mapbox.

Either in an .env file enter:

MAP_ACCESS_TOKEN='{INSERT_YOUR_TOKEN}'

or

In the config.py file replace {INSERT_YOUR_TOKEN}

  1. Run Server Flask
FLASK_DEBUG=true FLASK_APP=app/main.py flask run

or

Gunicorn

gunicorn main:app --error-logfile logs/error.log --access-logfile logs/access.log --pid app.pid --daemon --chdir app && tail -f logs/app.log
  1. Launch Browser

Either 127.0.0.1:5000 or 127.0.0.1:8000

  1. Stop Services

Flask Ctrl+C

or

Gunicorn

kill -s HUP $(cat app.pid) && kill -9 $(cat app.pid)

MongoDB

mongo --eval "db.getSiblingDB('admin').shutdownServer()"

Colophon

Considerations for Improvement

  • Sanitize input when leaving a review. As of now XSS is possible.
  • Dependency injection for backend code to clean up global variables.
  • Extract JS template strings to script tags with 'type="text/x-template"' to separate presentation and functionality.

About

Example geolocation web application using the Python, MongoDB, and JQuery with Bootstrap.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published