diff --git a/.github/workflows/canvas-sync-ruby-update.yml b/.github/workflows/canvas-sync-ruby-update.yml new file mode 100644 index 0000000..f8818dc --- /dev/null +++ b/.github/workflows/canvas-sync-ruby-update.yml @@ -0,0 +1,31 @@ +name: Sync with Canvas Ruby v2.7 + +on: + push: + branches: [master, main] + paths: + - 'README.md' + +jobs: + sync: + name: Sync with Canvas + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: 2.7 + + - name: Install github-to-canvas + run: gem install github-to-canvas + + # Secret stored in learn-co-curriculum Settings/Secrets + - name: Sync from .canvas file + run: github-to-canvas -a -lr + env: + CANVAS_API_KEY: ${{ secrets.CANVAS_API_KEY }} + CANVAS_API_PATH: ${{ secrets.CANVAS_API_PATH }} diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9a787a2 --- /dev/null +++ b/.gitignore @@ -0,0 +1,66 @@ +.DS_Store +# See https://help.github.com/articles/ignoring-files for more about ignoring files. +# +# If you find yourself ignoring temporary files generated by your text editor +# or operating system, you probably want to add a global ignore instead: +# git config --global core.excludesfile '.gitignore_global' + +# Ignore bundler config. +/.bundle + +# Ignore the default SQLite database. +/db/*.sqlite3 +/db/*.sqlite3-* + +# Ignore all logfiles and tempfiles. +/log/* +/tmp/* +!/log/.keep +!/tmp/.keep + +# Runtime data +pids +*.pid +*.seed +# Ignore uploaded files in development. +/storage/* +!/storage/.keep +.byebug_history + +# Ignore master key for decrypting credentials and more. +/config/master.key + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Compiled binary addons (http://nodejs.org/api/addons.html) +build/Release + +# Dependency directories +node_modules +jspm_packages + +# Optional npm cache directory +.npm + +# Optional REPL history +.node_repl_history + +# Learn-specific .results.json +.results.json + +# Ignore bundler config. +/.bundle + +# Virtual env metadata +.venv + +# pytest cache +.pytest_cache +__pycache__ + +# database +*.db +instance +.vscode +package-lock.json diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..33ecf8a --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,38 @@ +# Contributing to Learn.co Curriculum + +We're really exited that you're about to contribute to the [open +curriculum](https://learn.co/content-license) on [Learn.co](https://learn.co). +If this is your first time contributing, please continue reading to learn how to +make the most meaningful and useful impact possible. + +## Raising an Issue to Encourage a Contribution + +If you notice a problem with the curriculum that you believe needs improvement +but you're unable to make the change yourself, you should raise a Github issue +containing a clear description of the problem. Include relevant snippets of the +content and/or screenshots if applicable. Curriculum owners regularly review +issue lists and your issue will be prioritized and addressed as appropriate. + +## Submitting a Pull Request to Suggest an Improvement + +If you see an opportunity for improvement and can make the change yourself go +ahead and use a typical git workflow to make it happen: + +- Fork this curriculum repository +- Make the change on your fork, with descriptive commits in the standard format +- Open a Pull Request against this repo + +A curriculum owner will review your change and approve or comment on it in due +course. + +## Why Contribute? + +Curriculum on Learn is publicly and freely available under Learn's +[Educational Content License](https://learn.co/content-license). By embracing an +open-source contribution model, our goal is for the curriculum on Learn to +become, in time, the best educational content the world has ever seen. + +We need help from the community of Learners to maintain and improve the +educational content. Everything from fixing typos, to correcting out-dated +information, to improving exposition, to adding better examples, to fixing +tests—all contributions to making the curriculum more effective are welcome. diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..4694fa6 --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,23 @@ +# Learn.co Educational Content License + +Copyright (c) 2021 Flatiron School, Inc + +The Flatiron School, Inc. owns this Educational Content. However, the Flatiron +School supports the development and availability of educational materials in the +public domain. Therefore, the Flatiron School grants Users of the Flatiron +Educational Content set forth in this repository certain rights to reuse, build +upon and share such Educational Content subject to the terms of the Educational +Content License set forth [here](http://learn.co/content-license) +(http://learn.co/content-license). You must read carefully the terms and +conditions contained in the Educational Content License as such terms govern +access to and use of the Educational Content. + +Flatiron School is willing to allow you access to and use of the Educational +Content only on the condition that you accept all of the terms and conditions +contained in the Educational Content License set forth +[here](http://learn.co/content-license) (http://learn.co/content-license). By +accessing and/or using the Educational Content, you are agreeing to all of the +terms and conditions contained in the Educational Content License. If you do not +agree to any or all of the terms of the Educational Content License, you are +prohibited from accessing, reviewing or using in any way the Educational +Content. diff --git a/Pipfile b/Pipfile new file mode 100644 index 0000000..9c0ba76 --- /dev/null +++ b/Pipfile @@ -0,0 +1,18 @@ +[[source]] +url = "https://pypi.org/simple" +verify_ssl = true +name = "pypi" + +[packages] +ipdb = "0.13.9" +flask = "*" +flask-sqlalchemy = "3.0.3" +Werkzeug = "2.2.2" +flask-migrate = "*" +sqlalchemy-serializer = "*" +flask-restful = "*" +flask-cors = "*" +faker = "*" + +[requires] +python_full_version = "3.8.13" diff --git a/README.md b/README.md new file mode 100644 index 0000000..c71c9b0 --- /dev/null +++ b/README.md @@ -0,0 +1,357 @@ +# Phase 4 Full-Stack Application Project Template + +## Learning Goals + +- Discuss the basic directory structure of a full-stack Flask/React application. +- Carry out the first steps in creating your Phase 4 project. + +--- + +## Introduction + +Fork and clone this lesson for a template for your full-stack application. Take +a look at the directory structure before we begin (NOTE: node_modules will be +generated in a subsequent step): + +```console +$ tree -L 2 +$ # the -L argument limits the depth at which we look into the directory structure +. +├── CONTRIBUTING.md +├── LICENSE.md +├── Pipfile +├── README.md +├── client +│ ├── README.md +│ ├── package.json +│ ├── public +│ └── src +└── server + ├── app.py + ├── config.py + ├── models.py + └── seed.py +``` + +A `migrations` folder will be added to the `server` directory in a later step. + +The `client` folder contains a basic React application, while the `server` +folder contains a basic Flask application. You will adapt both folders to +implement the code for your project . + +NOTE: If you did not previously install `tree` in your environment setup, MacOS +users can install this with the command `brew install tree`. WSL and Linux users +can run `sudo apt-get install tree` to download it as well. + +## Where Do I Start? + +Just as with your Phase 3 Project, this will likely be one of the biggest +projects you've undertaken so far. Your first task should be creating a Git +repository to keep track of your work and roll back any undesired changes. + +### Removing Existing Git Configuration + +If you're using this template, start off by removing the existing metadata for +Github and Canvas. Run the following command to carry this out: + +```console +$ rm -rf .git .canvas +``` + +The `rm` command removes files from your computer's memory. The `-r` flag tells +the console to remove _recursively_, which allows the command to remove +directories and the files within them. `-f` removes them permanently. + +`.git` contains this directory's configuration to track changes and push to +Github (you want to track and push _your own_ changes instead), and `.canvas` +contains the metadata to create a Canvas page from your Git repo. You don't have +the permissions to edit our Canvas course, so it's not worth keeping around. + +### Creating Your Own Git Repo + +First things first- rename this directory! Once you have an idea for a name, +move one level up with `cd ..` and run +`mv python-p4-project-template ` to change its name (replace + with an appropriate project directory name). + +> **Note: If you typed the `mv` command in a terminal within VS Code, you should +> close VS Code then reopen it.** + +> **Note: `mv` actually stands for "move", but your computer interprets this +> rename as a move from a directory with the old name to a directory with a new +> name.** + +`cd` back into your new directory and run `git init` to create a local git +repository. Add all of your local files to version control with `git add --all`, +then commit them with `git commit -m'initial commit'`. (You can change the +message here- this one is just a common choice.) + +Navigate to [GitHub](https://github.com). In the upper-right corner of the page, +click on the "+" dropdown menu, then select "New repository". Enter the name of +your local repo, choose whether you would like it to be public or private, make +sure "Initialize this repository with a README" is unchecked (you already have +one), then click "Create repository". + +Head back to the command line and enter +`git remote add origin git@github.com:github-username/new-repository-name.git`. +NOTE: Replace `github-username` with your github username, and +`new-repository-name` with the name of your new repository. This command will +map the remote repository to your local repository. Finally, push your first +commit with `git push -u origin main`. + +Your project is now version-controlled locally and online. This will allow you +to create different versions of your project and pick up your work on a +different machine if the need arises. + +--- + +## Setup + +### `server/` + +The `server/` directory contains all of your backend code. + +`app.py` is your Flask application. You'll want to use Flask to build a simple +API backend like we have in previous modules. You should use Flask-RESTful for +your routes. You should be familiar with `models.py` and `seed.py` by now, but +remember that you will need to use Flask-SQLAlchemy, Flask-Migrate, and +SQLAlchemy-Serializer instead of SQLAlchemy and Alembic in your models. + +The project contains a default `Pipfile` with some basic dependencies. You may +adapt the `Pipfile` if there are additional dependencies you want to add for +your project. + +To download the dependencies for the backend server, run: + +```console +pipenv install +pipenv shell +``` + +You can run your Flask API on [`localhost:5555`](http://localhost:5555) by +running: + +```console +python server/app.py +``` + +Check that your server serves the default route `http://localhost:5555`. You +should see a web page with the heading "Project Server". + +### `client/` + +The `client/` directory contains all of your frontend code. The file +`package.json` has been configured with common React application dependencies, +include `react-router-dom`. The file also sets the `proxy` field to forward +requests to `"http://localhost:5555". Feel free to change this to another port- +just remember to configure your Flask app to use another port as well! + +To download the dependencies for the frontend client, run: + +```console +npm install --prefix client +``` + +You can run your React app on [`localhost:3000`](http://localhost:3000) by +running: + +```sh +npm start --prefix client +``` + +Check that your the React client displays a default page +`http://localhost:3000`. You should see a web page with the heading "Project +Client". + +## Generating Your Database + +NOTE: The initial project directory structure does not contain the `instance` or +`migrations` folders. Change into the `server` directory: + +```console +cd server +``` + +Then enter the commands to create the `instance` and `migrations` folders and +the database `app.db` file: + +``` +flask db init +flask db upgrade head +``` + +Type `tree -L 2` within the `server` folder to confirm the new directory +structure: + +```console +. +├── app.py +├── config.py +├── instance +│ └── app.db +├── migrations +│ ├── README +│ ├── __pycache__ +│ ├── alembic.ini +│ ├── env.py +│ ├── script.py.mako +│ └── versions +├── models.py +└── seed.py +``` + +Edit `models.py` and start creating your models. Import your models as needed in +other modules, i.e. `from models import ...`. + +Remember to regularly run +`flask db revision --autogenerate -m''`, replacing +`` with an appropriate message, and `flask db upgrade head` +to track your modifications to the database and create checkpoints in case you +ever need to roll those modifications back. + +> **Tip: It's always a good idea to start with an empty revision! This allows +> you to roll all the way back while still holding onto your database. You can +> create this empty revision with `flask db revision -m'Create DB'`.** + +If you want to seed your database, now would be a great time to write out your +`seed.py` script and run it to generate some test data. Faker has been included +in the Pipfile if you'd like to use that library. + +--- + +#### `config.py` + +When developing a large Python application, you might run into a common issue: +_circular imports_. A circular import occurs when two modules import from one +another, such as `app.py` and `models.py`. When you create a circular import and +attempt to run your app, you'll see the following error: + +```console +ImportError: cannot import name +``` + +If you're going to need an object in multiple modules like `app` or `db`, +creating a _third_ module to instantiate these objects can save you a great deal +of circular grief. Here's a good start to a Flask config file (you may need more +if you intend to include features like authentication and passwords): + +```py +# Standard library imports + +# Remote library imports +from flask import Flask +from flask_cors import CORS +from flask_migrate import Migrate +from flask_restful import Api +from flask_sqlalchemy import SQLAlchemy +from sqlalchemy import MetaData + +# Local imports + +# Instantiate app, set attributes +app = Flask(__name__) +app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///app.db' +app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False +app.json.compact = False + +# Define metadata, instantiate db +metadata = MetaData(naming_convention={ + "fk": "fk_%(table_name)s_%(column_0_name)s_%(referred_table_name)s", +}) +db = SQLAlchemy(metadata=metadata) +migrate = Migrate(app, db) +db.init_app(app) + +# Instantiate REST API +api = Api(app) + +# Instantiate CORS +CORS(app) + +``` + +Now let's review that last line... + +#### CORS + +CORS (Cross-Origin Resource Sharing) is a system that uses HTTP headers to +determine whether resources from different servers-of-origin can be accessed. If +you're using the fetch API to connect your frontend to your Flask backend, you +need to configure CORS on your Flask application instance. Lucky for us, that +only takes one line: + +```py +CORS(app) + +``` + +By default, Flask-CORS enables CORS on all routes in your application with all +fetching servers. You can also specify the resources that allow CORS. The +following specifies that routes beginning with `api/` allow CORS from any +originating server: + +```py +CORS(app, resources={r"/api/*": {"origins": "*"}}) + +``` + +You can also set this up resource-by-resource by importing and using the +`@cross_origin` decorator: + +```py +@app.route("/") +@cross_origin() +def howdy(): + return "Howdy partner!" + +``` + +--- + +## Updating Your README.md + +`README.md` is a Markdown file that describes your project. These files can be +used in many different ways- you may have noticed that we use them to generate +entire Canvas lessons- but they're most commonly used as homepages for online +Git repositories. **When you develop something that you want other people to +use, you need to have a README.** + +Markdown is not a language that we cover in Flatiron's Software Engineering +curriculum, but it's not a particularly difficult language to learn (if you've +ever left a comment on Reddit, you might already know the basics). Refer to the +cheat sheet in this lesson's resources for a basic guide to Markdown. + +### What Goes into a README? + +This README should serve as a template for your own- go through the important +files in your project and describe what they do. Each file that you edit (you +can ignore your migration files) should get at least a paragraph. Each function +should get a small blurb. + +You should descibe your application first, and with a good level of detail. The +rest should be ordered by importance to the user. (Probably routes next, then +models.) + +Screenshots and links to resources that you used throughout are also useful to +users and collaborators, but a little more syntactically complicated. Only add +these in if you're feeling comfortable with Markdown. + +--- + +## Conclusion + +A lot of work goes into a full-stack application, but it all relies on concepts +that you've practiced thoroughly throughout this phase. Hopefully this template +and guide will get you off to a good start with your Phase 4 Project. + +Happy coding! + +--- + +## Resources + +- [Setting up a respository - Atlassian](https://www.atlassian.com/git/tutorials/setting-up-a-repository) +- [Create a repo- GitHub Docs](https://docs.github.com/en/get-started/quickstart/create-a-repo) +- [Markdown Cheat Sheet](https://www.markdownguide.org/cheat-sheet/) +- [Python Circular Imports - StackAbuse](https://stackabuse.com/python-circular-imports/) +- [Flask-CORS](https://flask-cors.readthedocs.io/en/latest/) diff --git a/client/.gitignore b/client/.gitignore new file mode 100644 index 0000000..4d29575 --- /dev/null +++ b/client/.gitignore @@ -0,0 +1,23 @@ +# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. + +# dependencies +/node_modules +/.pnp +.pnp.js + +# testing +/coverage + +# production +/build + +# misc +.DS_Store +.env.local +.env.development.local +.env.test.local +.env.production.local + +npm-debug.log* +yarn-debug.log* +yarn-error.log* diff --git a/client/README.md b/client/README.md new file mode 100644 index 0000000..0c83cde --- /dev/null +++ b/client/README.md @@ -0,0 +1,70 @@ +# Getting Started with Create React App + +This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app). + +## Available Scripts + +In the project directory, you can run: + +### `npm start` + +Runs the app in the development mode.\ +Open [http://localhost:3000](http://localhost:3000) to view it in the browser. + +The page will reload if you make edits.\ +You will also see any lint errors in the console. + +### `npm test` + +Launches the test runner in the interactive watch mode.\ +See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information. + +### `npm run build` + +Builds the app for production to the `build` folder.\ +It correctly bundles React in production mode and optimizes the build for the best performance. + +The build is minified and the filenames include the hashes.\ +Your app is ready to be deployed! + +See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information. + +### `npm run eject` + +**Note: this is a one-way operation. Once you `eject`, you can’t go back!** + +If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project. + +Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own. + +You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it. + +## Learn More + +You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started). + +To learn React, check out the [React documentation](https://reactjs.org/). + +### Code Splitting + +This section has moved here: [https://facebook.github.io/create-react-app/docs/code-splitting](https://facebook.github.io/create-react-app/docs/code-splitting) + +### Analyzing the Bundle Size + +This section has moved here: [https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size](https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size) + +### Making a Progressive Web App + +This section has moved here: [https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app](https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app) + +### Advanced Configuration + +This section has moved here: [https://facebook.github.io/create-react-app/docs/advanced-configuration](https://facebook.github.io/create-react-app/docs/advanced-configuration) + +### Deployment + +This section has moved here: [https://facebook.github.io/create-react-app/docs/deployment](https://facebook.github.io/create-react-app/docs/deployment) + +### `npm run build` fails to minify + +This section has moved here: [https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify](https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify) diff --git a/client/package.json b/client/package.json new file mode 100644 index 0000000..2e4db73 --- /dev/null +++ b/client/package.json @@ -0,0 +1,41 @@ +{ + "name": "client", + "version": "0.1.0", + "private": true, + "proxy": "http://localhost:5555", + "dependencies": { + "@testing-library/jest-dom": "^5.17.0", + "@testing-library/react": "^13.4.0", + "@testing-library/user-event": "^13.5.0", + "react": "^18.2.0", + "react-dom": "^18.2.0", + "react-router-dom": "^5.2.0", + "react-scripts": "5.0.1", + "web-vitals": "^2.1.4" + }, + "devDependencies": {"@babel/plugin-proposal-private-property-in-object":"^7.21.11"}, + "scripts": { + "start": "react-scripts start", + "build": "react-scripts build", + "test": "react-scripts test", + "eject": "react-scripts eject" + }, + "eslintConfig": { + "extends": [ + "react-app", + "react-app/jest" + ] + }, + "browserslist": { + "production": [ + ">0.2%", + "not dead", + "not op_mini all" + ], + "development": [ + "last 1 chrome version", + "last 1 firefox version", + "last 1 safari version" + ] + } +} diff --git a/client/public/favicon.ico b/client/public/favicon.ico new file mode 100644 index 0000000..a11777c Binary files /dev/null and b/client/public/favicon.ico differ diff --git a/client/public/index.html b/client/public/index.html new file mode 100644 index 0000000..a7bfc83 --- /dev/null +++ b/client/public/index.html @@ -0,0 +1,48 @@ + + + + + + + + + + + + + + + Reciplease + + + +
+ + + diff --git a/client/public/logo192.png b/client/public/logo192.png new file mode 100644 index 0000000..fc44b0a Binary files /dev/null and b/client/public/logo192.png differ diff --git a/client/public/logo512.png b/client/public/logo512.png new file mode 100644 index 0000000..a4e47a6 Binary files /dev/null and b/client/public/logo512.png differ diff --git a/client/public/manifest.json b/client/public/manifest.json new file mode 100644 index 0000000..080d6c7 --- /dev/null +++ b/client/public/manifest.json @@ -0,0 +1,25 @@ +{ + "short_name": "React App", + "name": "Create React App Sample", + "icons": [ + { + "src": "favicon.ico", + "sizes": "64x64 32x32 24x24 16x16", + "type": "image/x-icon" + }, + { + "src": "logo192.png", + "type": "image/png", + "sizes": "192x192" + }, + { + "src": "logo512.png", + "type": "image/png", + "sizes": "512x512" + } + ], + "start_url": ".", + "display": "standalone", + "theme_color": "#000000", + "background_color": "#ffffff" +} diff --git a/client/public/robots.txt b/client/public/robots.txt new file mode 100644 index 0000000..e9e57dc --- /dev/null +++ b/client/public/robots.txt @@ -0,0 +1,3 @@ +# https://www.robotstxt.org/robotstxt.html +User-agent: * +Disallow: diff --git a/client/src/components/App.js b/client/src/components/App.js new file mode 100644 index 0000000..af444c5 --- /dev/null +++ b/client/src/components/App.js @@ -0,0 +1,8 @@ +import React, { useEffect, useState } from "react"; +import { Switch, Route } from "react-router-dom"; + +function App() { + return

Project Client

; +} + +export default App; diff --git a/client/src/index.css b/client/src/index.css new file mode 100644 index 0000000..b457c32 --- /dev/null +++ b/client/src/index.css @@ -0,0 +1,7 @@ +:root { + --bg: #282c34; + --header: #fff; + --link: #61dafb; + --text: hsla(0, 0%, 100%, 0.88); +} + diff --git a/client/src/index.js b/client/src/index.js new file mode 100644 index 0000000..be98dc7 --- /dev/null +++ b/client/src/index.js @@ -0,0 +1,8 @@ +import React from "react"; +import App from "./components/App"; +import "./index.css"; +import { createRoot } from "react-dom/client"; + +const container = document.getElementById("root"); +const root = createRoot(container); +root.render(); diff --git a/server/app.py b/server/app.py new file mode 100644 index 0000000..d7f4c5b --- /dev/null +++ b/server/app.py @@ -0,0 +1,23 @@ +#!/usr/bin/env python3 + +# Standard library imports + +# Remote library imports +from flask import request +from flask_restful import Resource + +# Local imports +from config import app, db, api +# Add your model imports + + +# Views go here! + +@app.route('/') +def index(): + return '

Project Server

' + + +if __name__ == '__main__': + app.run(port=5555, debug=True) + diff --git a/server/config.py b/server/config.py new file mode 100644 index 0000000..b0603b3 --- /dev/null +++ b/server/config.py @@ -0,0 +1,31 @@ +# Standard library imports + +# Remote library imports +from flask import Flask +from flask_cors import CORS +from flask_migrate import Migrate +from flask_restful import Api +from flask_sqlalchemy import SQLAlchemy +from sqlalchemy import MetaData + +# Local imports + +# Instantiate app, set attributes +app = Flask(__name__) +app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///app.db' +app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False +app.json.compact = False + +# Define metadata, instantiate db +metadata = MetaData(naming_convention={ + "fk": "fk_%(table_name)s_%(column_0_name)s_%(referred_table_name)s", +}) +db = SQLAlchemy(metadata=metadata) +migrate = Migrate(app, db) +db.init_app(app) + +# Instantiate REST API +api = Api(app) + +# Instantiate CORS +CORS(app) diff --git a/server/models.py b/server/models.py new file mode 100644 index 0000000..c34c500 --- /dev/null +++ b/server/models.py @@ -0,0 +1,6 @@ +from sqlalchemy_serializer import SerializerMixin +from sqlalchemy.ext.associationproxy import association_proxy + +from config import db + +# Models go here! diff --git a/server/seed.py b/server/seed.py new file mode 100644 index 0000000..849d148 --- /dev/null +++ b/server/seed.py @@ -0,0 +1,17 @@ +#!/usr/bin/env python3 + +# Standard library imports +from random import randint, choice as rc + +# Remote library imports +from faker import Faker + +# Local imports +from app import app +from models import db + +if __name__ == '__main__': + fake = Faker() + with app.app_context(): + print("Starting seed...") + # Seed code goes here!