The project is created for Udacity Full Stack Nanodegree Programme.
Here are some lines of example code:
- catalog.py:
# Import flask and sqlalchemy library
from flask import Flask, render_template, request
from flask import redirect, url_for, flash, jsonify
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
# Import asc desc
from sqlalchemy import asc, desc
# Import for anti forgery state token
from flask import session as login_session
import random
import string
# Import for gconnect
from oauth2client.client import flow_from_clientsecrets
from oauth2client.client import FlowExchangeError
import httplib2
import json
from flask import make_response
import requests
# Import from database_setup.py
from database_setup import Base, User, Category, CatalogItem
# Create CLIENT_ID
CLIENT_ID = json.loads(open('client_secrets'
'.json', 'r').read())['web']['client_id']
APPLICATION_NAME = "Catalog Item App"
app = Flask(__name__)
# Create database connection
engine = create_engine('sqlite:///catalog.db')
Base.metadata.bind = engine
DBSession = sessionmaker(bind=engine)
session = DBSession()
# Making anti-forgery state token
@app.route('/login')
def showLogin():
state = ''.join(random.choice(string.ascii_uppercase string.digits)
for x in xrange(32))
login_session['state'] = state
return render_template('login.html', STATE=state)
This is one of projects of Full Stack Udacity Nanodegree. Main reason is to evaluate the skills I have learnt (CRUD, API Endpoint, OAuth...).
After login with you Google Account, you can create/edit/delete your own category, item. Without login, you will be able to check the catalog items in the front page.
- You need to have code editor like
Atom
to modify the code - Vagrant
- VirtualBox
- You need to have Google Account to setup OAuth 2.0
- Clone this project (Using
https://github.com/vietdang7/catalog.git
or through your GitDesktop application) - Install VirtualBox
- Install Vagrant
- Download this FSND-Virtual-Machine.zip from Udacity (this will install all needed OS, software in your VirtualBox)
- Unzip the file, change to this directory in your terminal -
cd
command.
- Move cloned folder
catalog
tovagrant
folder - Run Vagrant by type
vagrant up
, andvagrant ssh
to log in - Move to catalog folder in vagrant by entering
cd /vagrant/catalog
- Run application by entering:
python catalog.py
- Open
http://locahost:5000
in your browser to test application
- Python3
- Flask
- SQLalchemy
- SQLite
- HTML
- CSS
- Bootstrap
If you want to make contribution for this project, feel free to fork
this project and make pull request
- Copyright of FSND-Virtual-Machine.zip are belong to Udacity.
- This project is licensed under the MIT license