Skip to content

Commit a0ffcc3

Browse files
authored
Merge pull request #42 from jungleBadger/main
Modifications to support Python 3.10 runtime
2 parents 7d64e39 + 722db93 commit a0ffcc3

File tree

5 files changed

+36
-36
lines changed

5 files changed

+36
-36
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,6 @@ venv
1212
ehthumbs.db
1313
Thumbs.db
1414
env/
15-
frontend/node_modules/
15+
frontend/node_modules/
16+
17+
.env

backend/flaskr/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
import os
21
from flask import Flask, request, abort, jsonify
3-
from flask_sqlalchemy import SQLAlchemy
42
from flask_cors import CORS
53
import random
64

7-
from models import setup_db, Question, Category
5+
from models import setup_db, Question, Category, db
86

97
QUESTIONS_PER_PAGE = 10
108

@@ -21,6 +19,8 @@ def create_app(test_config=None):
2119
"""
2220
@TODO: Set up CORS. Allow '*' for origins. Delete the sample route after completing the TODOs
2321
"""
22+
with app.app_context():
23+
db.create_all()
2424

2525
"""
2626
@TODO: Use the after_request decorator to set Access-Control-Allow

backend/models.py

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import os
2-
from sqlalchemy import Column, String, Integer, create_engine
1+
from sqlalchemy import Column, String, Integer
32
from flask_sqlalchemy import SQLAlchemy
4-
import json
5-
63
database_name = 'trivia'
7-
database_path = 'postgresql://{}/{}'.format('localhost:5432', database_name)
4+
database_user = 'postgres'
5+
database_password = 'password'
6+
database_host = 'localhost:5432'
7+
database_path = f'postgresql://{database_user}:{database_password}@{database_host}/{database_name}'
88

99
db = SQLAlchemy()
1010

@@ -13,24 +13,21 @@
1313
binds a flask application and a SQLAlchemy service
1414
"""
1515
def setup_db(app, database_path=database_path):
16-
app.config["SQLALCHEMY_DATABASE_URI"] = database_path
17-
app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False
18-
db.app = app
16+
app.config['SQLALCHEMY_DATABASE_URI'] = database_path
17+
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
1918
db.init_app(app)
20-
db.create_all()
2119

2220
"""
2321
Question
24-
2522
"""
2623
class Question(db.Model):
2724
__tablename__ = 'questions'
2825

2926
id = Column(Integer, primary_key=True)
30-
question = Column(String)
31-
answer = Column(String)
32-
category = Column(String)
33-
difficulty = Column(Integer)
27+
question = Column(String, nullable=False)
28+
answer = Column(String, nullable=False)
29+
category = Column(String, nullable=False)
30+
difficulty = Column(Integer, nullable=False)
3431

3532
def __init__(self, question, answer, category, difficulty):
3633
self.question = question
@@ -56,17 +53,16 @@ def format(self):
5653
'answer': self.answer,
5754
'category': self.category,
5855
'difficulty': self.difficulty
59-
}
56+
}
6057

6158
"""
6259
Category
63-
6460
"""
6561
class Category(db.Model):
6662
__tablename__ = 'categories'
6763

6864
id = Column(Integer, primary_key=True)
69-
type = Column(String)
65+
type = Column(String, nullable=False)
7066

7167
def __init__(self, type):
7268
self.type = type
@@ -75,4 +71,4 @@ def format(self):
7571
return {
7672
'id': self.id,
7773
'type': self.type
78-
}
74+
}

backend/requirements.txt

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
aniso8601==6.0.0
2-
Click==7.0
3-
Flask==1.0.3
4-
Flask-Cors==3.0.7
5-
Flask-RESTful==0.3.7
6-
Flask-SQLAlchemy==2.4.0
7-
itsdangerous==1.1.0
8-
Jinja2==2.10.1
9-
MarkupSafe==1.1.1
10-
psycopg2-binary==2.8.2
11-
pytz==2019.1
12-
six==1.12.0
13-
SQLAlchemy==1.3.4
14-
Werkzeug==0.15.5
1+
aniso8601>=9.0.1
2+
Click>=8.0.0
3+
Flask>=2.0.0
4+
Flask-Cors>=3.0.10
5+
Flask-RESTful>=0.3.9
6+
Flask-SQLAlchemy>=2.5.1
7+
itsdangerous>=2.0.0
8+
Jinja2>=3.0.0
9+
MarkupSafe>=2.0.0
10+
psycopg2-binary>=2.9.0
11+
pytz>=2021.1
12+
six>=1.16.0
13+
SQLAlchemy>=1.4.0
14+
Werkzeug>=2.0.0

frontend/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
77
### Installing Dependencies
88

9+
Recommended node version: 16x
10+
911
1. **Installing Node and NPM**
1012
This project depends on Nodejs and Node Package Manager (NPM). Before continuing, you must download and install Node (the download includes NPM) from [https://nodejs.com/en/download](https://nodejs.org/en/download/).
1113

0 commit comments

Comments
 (0)