Skip to content

Commit debea92

Browse files
committed
got the mongodb server working
wish i could specify it in .flaskenv but whatever
1 parent dced3f6 commit debea92

File tree

7 files changed

+16
-5
lines changed

7 files changed

+16
-5
lines changed

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
venv/
2-
*.pyc
2+
*.pyc
3+
4+
data/db/*
5+
!data/db/database.md

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
- flask
44
- python-dotenv
5+
- Flask-PyMongo
56

67
# run
78

@@ -10,13 +11,15 @@ run with `--host=0.0.0.0` for local network testing
1011
### windows
1112

1213
```
14+
> mongod --dbpath .\data\db
1315
> venv\Scripts\activate
1416
> flask run
1517
```
1618

1719
### linux
1820

1921
```
22+
$ mongod --dbpath ./data/db
2023
$ source ./venv/bin/activate
2124
$ flask run
2225
```

app/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
from flask import Flask
2+
from flask_pymongo import PyMongo
23

34
app = Flask(__name__)
45

6+
app.config["MONGO_URI"] = "mongodb://localhost:27017/"
7+
mongo = PyMongo(app)
8+
59
from app import routes

app/routes.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
from flask import render_template, abort
2-
from app import app
2+
from app import app, mongo
33
import json, os, time
44

5-
DATA_FILENAME = "./app/data.json"
5+
DATA_FILENAME = "./data/data.json"
66
data = {}
77
last_updated = 0
88

app/templates/projects/cookee.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
{% block content %}
44
<div class="section">
55
<div class="container container-single">
6-
<h1>Cookee <a href="https://github.com/richzli/cookee" target="_blank"><img class="project-icon-link" src="{{ url_for('static', filename='resources/logos/github.svg') }}" height="30" /></a></h1>
6+
<h1>cookee <a href="https://github.com/richzli/cookee" target="_blank"><img class="project-icon-link" src="{{ url_for('static', filename='resources/logos/github.svg') }}" height="30" /></a></h1>
77
</div>
88
</div>
99
<div class="section">

app/data.json renamed to data/data.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
},
1515
{
1616
"name": "cookee",
17-
"title": "Cookee",
17+
"title": "cookee",
1818
"link": "cookee",
1919
"img": "cookee-logo.png"
2020
},

data/db/database.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
This is where the database is stored. I'm gitignoring all of the database files so stuff doesn't get clogged up. This file exists so that git will correctly create the `./data/db` folder.

0 commit comments

Comments
 (0)