APP LINK:- https://calm-wave-79025.herokuapp.com/
npm install
pip install -r requirements.txt
- Run
echo "DANGEROUSLY_DISABLE_HOST_CHECK=true" > .env.development.local
in the project directory
- Run command in terminal (in your project directory):
python app.py
- Run command in another terminal,
cd
into the project directory, and runnpm run start
- Preview web page in browser '/'
- In your terminal, go to the directory with
app.py
. - Let's set up a new remote Postgres database with Heroku and connect to it locally.
- Login and fill creds:
heroku login -i
- Create a new Heroku app:
heroku create
- Create a new remote DB on your Heroku app:
heroku addons:create heroku-postgresql:hobby-dev
(If that doesn't work, add a-a {your-app-name}
to the end of the command, no braces) - See the config vars set by Heroku for you:
heroku config
. Copy paste the value for DATABASE_URL - Set the value of
DATABASE_URL
as an environment variable by entering this in the terminal:export DATABASE_URL='copy-paste-value-in-here'
(mine looked like thisexport DATABASE_URL='postgres://lkmlrinuazynlb:b94acaa351c0ecdaa7d60ce75f7ccaf40c2af646281bd5b1a2787c2eb5114be4@ec2-54-164-238-108.compute-1.amazonaws.com:5432/d1ef9avoe3r77f'
)
- In the terminal, run
python
to open up an interactive session. Let's initialize a new database and add some dummy data in it using SQLAlchemy functions. Then type in these Python lines one by one:
>> from app import db
>> import models
>> db.create_all()
>> admin = models.Person(username='admin', score='250')
>> guest = models.Person(username='guest', score='99')
>> db.session.add(admin)
>> db.session.add(guest)
>> db.session.commit()
- In your same
python
session, let's now make sure that data was added successfully by doing some queries.
>> models.Person.query.all()
[<Person u'admin'>, <Person u'guest'>] # output
>> models.Person.query.filter_by(username='admin').first()
<Person u'admin'> # output
- Now let's make sure this was written to our Heroku remote database! Let's connect to it using:
heroku pg:psql
\d
to list all our tables.person
should be in there now.- Now let's query the data with a SQL query (you will submit screenshots of the output in Canvas):
SELECT * FROM person;
SELECT email FROM person WHERE username='admin';
- Create a Heroku app:
heroku create --buildpack heroku/python
- Add nodejs buildpack:
heroku buildpacks:add --index 1 heroku/nodejs
- Push to Heroku:
git push heroku main
- Controling user clicks on board: If I had more time and resources I would do more reasearch on how to allow first 2 users to control board 'X' or 'O' respectively and others as 'Spectator'.
- Implementation of Database: On window close I cannot track which user have exited because I am not using a database. If I had database I would add a database which can track user info and can be updated live when user joins and exit.
- Making LeadBoard
- Making Restart button to emit empty Board to all users: I was trying to use setBoard function to make board empty by passing "Array(9).fill(null)" into the function. I was getting error for passing empty array in the setBoard function. After trying lots of diffrent techniques to make board restart I discoverd I just have to emit empty array dirrectly instead of calling setBoard.
- I accidentally deleted 2 files while I wanted to remove untracked file from git status. I used "git cleane -f -X" which I found from google to delete untracked files but Google does not always help. This command deleted ".env.development.local" and "sql.env", second file was not important to me beacuse I have not used a database in my code. But first file was an important file which caused my webpage to give an "Invalid host header."message on webpage instead of showing my actual page.