Created
July 4, 2015 08:22
-
-
Save hobo0cn/d896b350cf5d013c141c to your computer and use it in GitHub Desktop.
LP Server
This gist exceeds the recommended number of files (~10).
To access all files, please clone this gist.
This file contains hidden or 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
LP_server |
This file contains hidden or 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
<?xml version="1.0" encoding="UTF-8"?> | |
<module type="PYTHON_MODULE" version="4"> | |
<component name="NewModuleRootManager"> | |
<content url="file://$MODULE_DIR$" /> | |
<orderEntry type="inheritedJdk" /> | |
<orderEntry type="sourceFolder" forTests="false" /> | |
</component> | |
<component name="TemplatesService"> | |
<option name="TEMPLATE_CONFIGURATION" value="Jinja2" /> | |
<option name="TEMPLATE_FOLDERS"> | |
<list> | |
<option value="$MODULE_DIR$/venv/lib/python2.7/site-packages/flask/testsuite/templates" /> | |
</list> | |
</option> | |
</component> | |
</module> |
This file contains hidden or 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
<?xml version="1.0" encoding="UTF-8"?> | |
<project version="4"> | |
<component name="ProjectLevelVcsManager" settingsEditedManually="false"> | |
<OptionsSetting value="true" id="Add" /> | |
<OptionsSetting value="true" id="Remove" /> | |
<OptionsSetting value="true" id="Checkout" /> | |
<OptionsSetting value="true" id="Update" /> | |
<OptionsSetting value="true" id="Status" /> | |
<OptionsSetting value="true" id="Edit" /> | |
<ConfirmationsSetting value="0" id="Add" /> | |
<ConfirmationsSetting value="0" id="Remove" /> | |
</component> | |
<component name="ProjectRootManager" version="2" project-jdk-name="Python 2.7.6 virtualenv at ~/MyProjects/LP_server/venv" project-jdk-type="Python SDK" /> | |
</project> |
This file contains hidden or 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
<?xml version="1.0" encoding="UTF-8"?> | |
<project version="4"> | |
<component name="ProjectModuleManager"> | |
<modules> | |
<module fileurl="file://$PROJECT_DIR$/.idea/LP_server.iml" filepath="$PROJECT_DIR$/.idea/LP_server.iml" /> | |
</modules> | |
</component> | |
</project> |
This file contains hidden or 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
<?xml version="1.0" encoding="UTF-8"?> | |
<project version="4"> | |
<component name="VcsDirectoryMappings"> | |
<mapping directory="" vcs="" /> | |
</component> | |
</project> |
This file contains hidden or 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
SQLALCHEMY_DATABASE_URI = 'sqlite:////Users/hobo/MyProjects/LP_server/LP.db' | |
SQLALCHEMY_ECHO = False | |
SECRET_KEY = '\xfb\x12\xdf\xa1@i\xd6>V\xc0\xbb\x8fp\x16#Z\x0b\x81\xeb\x16' | |
DEBUG = True |
This file contains hidden or 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
from flask import Flask | |
import os | |
from database import db | |
__curdir__ = os.path.realpath(os.path.dirname(__file__)) | |
def create_app(): | |
app = Flask(__name__) | |
# app.config['DEBUG'] = True | |
# | |
# app.config['SQLALCHEMY_DATABASE_URI'] = "sqlite:///" +__curdir__ + "/LP.db" | |
app.config.from_pyfile('app.cfg') | |
db.init_app(app) | |
from ship import ship_bp | |
app.register_blueprint(ship_bp) | |
return app | |
def setup_database(app): | |
with app.app_context(): | |
db.create_all() | |
if __name__ == '__main__': | |
app = create_app() | |
#Because this is just a demostration we set up the database like this. | |
if not os.path.isfile(__curdir__ + "/LP.db"): | |
setup_database(app) | |
app.run() | |
This file contains hidden or 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
from flask.ext.sqlalchemy import SQLAlchemy | |
db = SQLAlchemy() |
This file contains hidden or 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
SQLite format 3 @ -� | |
� U D�U �l%%�tableship_historyship_historyCREATE TABLE ship_history ( | |
id INTEGER NOT NULL, | |
arrive_date DATETIME, | |
oil_name VARCHAR(50), | |
value INTEGER, | |
ship_id INTEGER, | |
PRIMARY KEY (id), | |
FOREIGN KEY(ship_id) REFERENCES ship (id) | |
)��{tableshipshipCREATE TABLE ship ( | |
id INTEGER NOT NULL, | |
name VARCHAR(50), | |
capacity INTEGER, | |
PRIMARY KEY (id), | |
UNIQUE (name) | |
)'; indexsqlite_autoindex_ship_1ship | |