Skip to content

Commit

Permalink
changed name
Browse files Browse the repository at this point in the history
  • Loading branch information
rakesh-krishna committed Apr 28, 2021
1 parent b7540b3 commit 4db5782
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 19 deletions.
Binary file modified database.db
Binary file not shown.
21 changes: 7 additions & 14 deletions init_db.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,13 @@
import sqlite3
def db_setup():
connection = sqlite3.connect('database.db')

connection = sqlite3.connect('database.db')

with open('schema.sql') as f:
connection.executescript(f.read())

with open('schema.sql') as f:
connection.executescript(f.read())
cur = connection.cursor()

cur = connection.cursor()

cur.execute("INSERT INTO posts (username, reason) VALUES (?, ?)",
('First Post', 'Content for the first post')
)

cur.execute("INSERT INTO posts (username, reason) VALUES (?, ?)",
('Second Post', 'Content for the second post')
)

connection.commit()
connection.close()
connection.commit()
connection.close()
8 changes: 3 additions & 5 deletions app.py → main.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import time


app = Flask(__name__)

def get_db_connection():
conn = sqlite3.connect('database.db')
conn.row_factory = sqlite3.Row
Expand All @@ -21,8 +23,6 @@ def get_post(post_id):
return post


app = Flask(__name__)
app.config['SECRET_KEY'] = 'your secret key'


@app.route('/')
Expand Down Expand Up @@ -182,6 +182,4 @@ def delete(id):
flash('"{}" was successfully deleted!'.format(post['username']))
return redirect(url_for('index'))

if __name__ == '__main__':
# app.run(host='0.0.0.0')
app.run()

Binary file modified requirements.txt
Binary file not shown.
5 changes: 5 additions & 0 deletions wsgi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from main import app
from init_db import db_setup
if __name__ == "__main__":
db_setup()
app.run()

0 comments on commit 4db5782

Please sign in to comment.