-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from Storj/SQLAlchemy
Add SQL Alchemy
- Loading branch information
Showing
2 changed files
with
37 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,25 @@ | ||
import sqlite3 | ||
from flask import Flask | ||
from contextlib import closing | ||
|
||
|
||
# Initialize the Flask application | ||
app = Flask(__name__) | ||
|
||
|
||
# Database code | ||
def init_db(): | ||
with closing(connect_db()) as db: | ||
with app.open_resource('schema.sql', mode='r') as f: | ||
db.cursor().executescript(f.read()) | ||
db.commit() | ||
|
||
|
||
def connect_db(): | ||
return sqlite3.connect(app.config['DATABASE']) | ||
|
||
|
||
# Routes | ||
@app.route('/') | ||
def index(): | ||
return "Hello World." | ||
|
||
|
||
# Routes | ||
@app.route('/api/register') | ||
def register(): | ||
return "Register Farmer Here." | ||
|
||
if __name__ == '__main__': | ||
# Run the Flask app | ||
app.run( | ||
host="0.0.0.0", | ||
port=int("5000"), | ||
debug=True | ||
) |