Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modifications to support Python 3.10 runtime #42

Merged
merged 6 commits into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,6 @@ venv
ehthumbs.db
Thumbs.db
env/
frontend/node_modules/
frontend/node_modules/

.env
6 changes: 3 additions & 3 deletions backend/flaskr/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import os
from flask import Flask, request, abort, jsonify
from flask_sqlalchemy import SQLAlchemy
from flask_cors import CORS
import random

from models import setup_db, Question, Category
from models import setup_db, Question, Category, db

QUESTIONS_PER_PAGE = 10

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

"""
@TODO: Use the after_request decorator to set Access-Control-Allow
Expand Down
32 changes: 14 additions & 18 deletions backend/models.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import os
from sqlalchemy import Column, String, Integer, create_engine
from sqlalchemy import Column, String, Integer
from flask_sqlalchemy import SQLAlchemy
import json

database_name = 'trivia'
database_path = 'postgresql://{}/{}'.format('localhost:5432', database_name)
database_user = 'postgres'
database_password = 'password'
database_host = 'localhost:5432'
database_path = f'postgresql://{database_user}:{database_password}@{database_host}/{database_name}'

db = SQLAlchemy()

Expand All @@ -13,24 +13,21 @@
binds a flask application and a SQLAlchemy service
"""
def setup_db(app, database_path=database_path):
app.config["SQLALCHEMY_DATABASE_URI"] = database_path
app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False
db.app = app
app.config['SQLALCHEMY_DATABASE_URI'] = database_path
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
db.init_app(app)
db.create_all()

"""
Question

"""
class Question(db.Model):
__tablename__ = 'questions'

id = Column(Integer, primary_key=True)
question = Column(String)
answer = Column(String)
category = Column(String)
difficulty = Column(Integer)
question = Column(String, nullable=False)
answer = Column(String, nullable=False)
category = Column(String, nullable=False)
difficulty = Column(Integer, nullable=False)

def __init__(self, question, answer, category, difficulty):
self.question = question
Expand All @@ -56,17 +53,16 @@ def format(self):
'answer': self.answer,
'category': self.category,
'difficulty': self.difficulty
}
}

"""
Category

"""
class Category(db.Model):
__tablename__ = 'categories'

id = Column(Integer, primary_key=True)
type = Column(String)
type = Column(String, nullable=False)

def __init__(self, type):
self.type = type
Expand All @@ -75,4 +71,4 @@ def format(self):
return {
'id': self.id,
'type': self.type
}
}
28 changes: 14 additions & 14 deletions backend/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
aniso8601==6.0.0
Click==7.0
Flask==1.0.3
Flask-Cors==3.0.7
Flask-RESTful==0.3.7
Flask-SQLAlchemy==2.4.0
itsdangerous==1.1.0
Jinja2==2.10.1
MarkupSafe==1.1.1
psycopg2-binary==2.8.2
pytz==2019.1
six==1.12.0
SQLAlchemy==1.3.4
Werkzeug==0.15.5
aniso8601>=9.0.1
Click>=8.0.0
Flask>=2.0.0
Flask-Cors>=3.0.10
Flask-RESTful>=0.3.9
Flask-SQLAlchemy>=2.5.1
itsdangerous>=2.0.0
Jinja2>=3.0.0
MarkupSafe>=2.0.0
psycopg2-binary>=2.9.0
pytz>=2021.1
six>=1.16.0
SQLAlchemy>=1.4.0
Werkzeug>=2.0.0
2 changes: 2 additions & 0 deletions frontend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

### Installing Dependencies

Recommended node version: 16x

1. **Installing Node and NPM**
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/).

Expand Down
Loading