##Toy Shop Online Mangement This is the third project for "Full Stack Web Developer Nanodegree" on Udacity.
You can use this website to manage toy shops.
##Before running this website, make sure all the required python modules have been installed. Please see Instructions.
##Instructions
- Clone this project to your local machine at first.
- use
pip install -r requirements.txt
to install neccessary python modules. - Use
python database_setup.py
to create database. - Use
python import_fake_data.py
to import fake data if you want to test this website. - Use
python website.py
to run this website on your local machine. - Open browser and navigate to http://localhost:5000/
##Features
- Using Flask ( a light Python web framework).
- Using OAuth 2.0 to Access Google APIs.
- You can login using your google account.
- Only the owner can manage his own shop.
- Using RESRfull APIs, like Post and Get.
- Providing JSON APIs, which you can exploit to get the information you want.
@app.route('/index/<string:shop_ID>/JSON/')
def shopJSON(shop_ID):
shops = session.query(ToyShop).filter_by(id=shop_ID).one()
toys = session.query(ToyItem).filter_by(shop_id = shop_ID).all()
return jsonify(Shop=shops.serialize, Toys = [g.serialize for g in toys])
@app.route('/index/<string:shop_ID>/<string:toy_ID>/JSON/')
def toyJSON(shop_ID,toy_ID):
toy = session.query(ToyItem).filter_by(id=toy_ID).one()
return jsonify(Toy = toy.serialize)
You can use url likes localhost:5000/index/<string:shop_ID>/JSON/
to get the JSON file corresponding to the shop with id = shop_ip;
You can use url likes localhost:5000/index/<string:shop_ID>/<string:toy_ID>/JSON/
to get the JSON file corresponding to the toy with id = toy_ID.
##You will see
The main page looks like:
You can use your google account to login: