It's a simple web server coded by Ruochen Xie, which has the function of creating, reading, updating and deleting data in restaurant and menu using flask and sqlAlchemy.
This is one of the projects from udacity full-stack nanodegree.
If running locally, it's a website which has a url: http://0.0.0.0:5000/ showing a list of fack restaurants, users can crud them and their menu.
- connect db
- define router
- define session
- execute sql using session
- import results into html templates or redirect to another url
- Implement a decorator function to check user login status
- Implement the ON DELETE CASCADE
- Include the csrf_token, flask-seasurf, dealing with the CRUD problem
- Install Vagrant and VirtualBox
- Download or Clone fullstack-nanodegree-vm repository. The file have a directory called vagrant.
- Put the project and the vangrant setup file into the same directory.
- Launch the Vagrant VM inside Vagrant sub-directory in the downloaded fullstack-nanodegree-vm repository using command:
$ vagrant up
- Then Log into this using command:
$ vagrant ssh
- Change directory to /vagrant and look around with ls. (如果出现文件无法同步的情况,尝试使用vagrant reload排查错误)
You can use the restaurantmenu.db directly or using the following command to creat a clean restaurantmenu.db:
- Create the database using the command:
python database_setup.py - Use
python setmenus.pyto populate the database
The database includes two tables which can be observed through database_setup.py:
- The restaurant table includes the name and id.
- The menue table includes the name, id, price, description, restaurant_id.
The web server contains four features:
- The CRUD of restaurant table
- The CRUD of menu table
- Return menu info using JSON
- authentication of github account
run it using
python webserverUsingFlask.py
Passing the pycodestyle (pycodestyle --first webserverUsingFlask.py) checking.