Compare commits

...

3 Commits

Author SHA1 Message Date
Derek d68be11789
Add a readme 2018-07-26 12:22:40 -07:00
Derek b793963d8f
Add setup script for easier first-time deployment 2018-07-26 12:21:48 -07:00
Derek 76509445ff
Use config.json instead of settings.cfg 2018-07-26 12:17:49 -07:00
7 changed files with 91 additions and 17 deletions

2
.gitignore vendored
View File

@ -1,3 +1,3 @@
__pycache__/
*.db
settings.cfg
config.json

View File

@ -10,6 +10,7 @@ flask-login = "*"
flask-sqlalchemy = "*"
bcrypt = "*"
flask-migrate = "*"
click = "*"
[dev-packages]

34
Pipfile.lock generated
View File

@ -1,7 +1,7 @@
{
"_meta": {
"hash": {
"sha256": "34cf8eeb4944ad3d68632638e8ce9993bd40618d2718864cfb222ba85d2ab735"
"sha256": "294652d06b03e0498836999c31a5a8e12c60ddb8074f2a5499604ab0f6abfb3b"
},
"pipfile-spec": 6,
"requires": {
@ -18,9 +18,10 @@
"default": {
"alembic": {
"hashes": [
"sha256:85bd3ea7633024e4930900bc64fb58f9742dedbc6ebb6ecf25be2ea9a3c1b32e"
"sha256:52d73b1d750f1414fa90c25a08da47b87de1e4ad883935718a8f36396e19e78e",
"sha256:eb7db9b4510562ec37c91d00b00d95fde076c1030d3f661aea882eec532b3565"
],
"version": "==0.9.9"
"version": "==1.0.0"
},
"bcrypt": {
"hashes": [
@ -36,7 +37,9 @@
"sha256:3b4c23300c4eded8895442c003ae9b14328ae69309ac5867e7530de8bdd7875d",
"sha256:43d1960e7db14042319c46925892d5fa99b08ff21d57482e6f5328a1aca03588",
"sha256:49e96267cd9be55a349fd74f9852eb9ae2c427cd7f6455d0f1765d7332292832",
"sha256:63e06ffdaf4054a89757a3a1ab07f1b922daf911743114a54f7c561b9e1baa58",
"sha256:67ed1a374c9155ec0840214ce804616de49c3df9c5bc66740687c1c9b1cd9e8d",
"sha256:6b662a5669186439f4f583636c8d6ea77cf92f7cfe6aae8d22edf16c36840574",
"sha256:6efd9ca20aefbaf2e7e6817a2c6ed4a50ff6900fafdea1bcb1d0e9471743b144",
"sha256:8569844a5d8e1fdde4d7712a05ab2e6061343ac34af6e7e3d7935b2bd1907bfd",
"sha256:8629ea6a8a59f865add1d6a87464c3c676e60101b8d16ef404d0a031424a8491",
@ -48,9 +51,12 @@
"sha256:b1e8491c6740f21b37cca77bc64677696a3fb9f32360794d57fa8477b7329eda",
"sha256:c906bdb482162e9ef48eea9f8c0d967acceb5c84f2d25574c7d2a58d04861df1",
"sha256:cb18ffdc861dbb244f14be32c47ab69604d0aca415bee53485fcea4f8e93d5ef",
"sha256:cc2f24dc1c6c88c56248e93f28d439ee4018338567b0bbb490ea26a381a29b1e",
"sha256:d860c7fff18d49e20339fc6dffc2d485635e36d4b2cccf58f45db815b64100b4",
"sha256:d86da365dda59010ba0d1ac45aa78390f56bf7f992e65f70b3b081d5e5257b09",
"sha256:e22f0997622e1ceec834fd25947dc2ee2962c2133ea693d61805bc867abaf7ea",
"sha256:f2fe545d27a619a552396533cddf70d83cecd880a611cdfdbb87ca6aec52f66b",
"sha256:f425e925485b3be48051f913dbe17e08e8c48588fdf44a26b8b14067041c0da6",
"sha256:f7fd3ed3745fe6e81e28dc3b3d76cce31525a91f32a387e1febd6b982caf8cdb",
"sha256:f9210820ee4818d84658ed7df16a7f30c9fba7d8b139959950acef91745cc0f7"
],
@ -63,9 +69,12 @@
"sha256:1553d1e99f035ace1c0544050622b7bc963374a00c467edafac50ad7bd276aef",
"sha256:1b0493c091a1898f1136e3f4f991a784437fac3673780ff9de3bcf46c80b6b50",
"sha256:2ba8a45822b7aee805ab49abfe7eec16b90587f7f26df20c71dd89e45a97076f",
"sha256:3bb6bd7266598f318063e584378b8e27c67de998a43362e8fce664c54ee52d30",
"sha256:3c85641778460581c42924384f5e68076d724ceac0f267d66c757f7535069c93",
"sha256:3eb6434197633b7748cea30bf0ba9f66727cdce45117a712b29a443943733257",
"sha256:495c5c2d43bf6cebe0178eb3e88f9c4aa48d8934aa6e3cddb865c058da76756b",
"sha256:4c91af6e967c2015729d3e69c2e51d92f9898c330d6a851bf8f121236f3defd3",
"sha256:57b2533356cb2d8fac1555815929f7f5f14d68ac77b085d2326b571310f34f6e",
"sha256:770f3782b31f50b68627e22f91cb182c48c47c02eb405fd689472aa7b7aa16dc",
"sha256:79f9b6f7c46ae1f8ded75f68cf8ad50e5729ed4d590c74840471fc2823457d04",
"sha256:7a33145e04d44ce95bcd71e522b478d282ad0eafaf34fe1ec5bbd73e662f22b6",
@ -74,11 +83,13 @@
"sha256:95d5251e4b5ca00061f9d9f3d6fe537247e145a8524ae9fd30a2f8fbce993b5b",
"sha256:9d1d3e63a4afdc29bd76ce6aa9d58c771cd1599fbba8cf5057e7860b203710dd",
"sha256:a36c5c154f9d42ec176e6e620cb0dd275744aa1d804786a71ac37dc3661a5e95",
"sha256:a6a5cb8809091ec9ac03edde9304b3ad82ad4466333432b16d78ef40e0cce0d5",
"sha256:ae5e35a2c189d397b91034642cb0eab0e346f776ec2eb44a49a459e6615d6e2e",
"sha256:b0f7d4a3df8f06cf49f9f121bead236e328074de6449866515cea4907bbc63d6",
"sha256:b75110fb114fa366b29a027d0c9be3709579602ae111ff61674d28c93606acca",
"sha256:ba5e697569f84b13640c9e193170e89c13c6244c24400fc57e88724ef610cd31",
"sha256:be2a9b390f77fd7676d80bc3cdc4f8edb940d8c198ed2d8c0be1319018c778e1",
"sha256:ca1bd81f40adc59011f58159e4aa6445fc585a32bb8ac9badf7a2c1aa23822f2",
"sha256:d5d8555d9bfc3f02385c1c37e9f998e2011f0db4f90e250e5bc0c0a85a813085",
"sha256:e55e22ac0a30023426564b1059b035973ec82186ddddbac867078435801c7801",
"sha256:e90f17980e6ab0f3c2f3730e56d1fe9bcba1891eeea58966e89d352492cc74f4",
@ -94,6 +105,7 @@
"sha256:29f99fc6125fbc931b758dc053b3114e55c77a6e4c6c3a2674a2dc986016381d",
"sha256:f15516df478d5a56180fbf80e68f206010e6d160fc39fa508b65e035fd75130b"
],
"index": "pypi",
"version": "==6.7"
},
"flask": {
@ -113,11 +125,11 @@
},
"flask-migrate": {
"hashes": [
"sha256:493f9b3795985b9b4915bf3b7d16946697f027b73545384e7d9e3a79f989d2fe",
"sha256:b709ca8642559c3c5a81a33ab10839fa052177accd5ba821047a99db635255ed"
"sha256:83ebc105f87357ddd3968f83510d2b1092f006660b1c6ba07a4efce036ca567d",
"sha256:cd1b4e6cb829eeb41c02ad9202d83bef5f4b7a036dd9fad72ce96ad1e22efb07"
],
"index": "pypi",
"version": "==2.1.1"
"version": "==2.2.1"
},
"flask-sqlalchemy": {
"hashes": [
@ -129,11 +141,11 @@
},
"gunicorn": {
"hashes": [
"sha256:7ef2b828b335ed58e3b64ffa84caceb0a7dd7c5ca12f217241350dec36a1d5dc",
"sha256:bc59005979efb6d2dd7d5ba72d99f8a8422862ad17ff3a16e900684630dd2a10"
"sha256:aa8e0b40b4157b36a5df5e599f45c9c76d6af43845ba3b3b0efe2c70473c2471",
"sha256:fa2662097c66f920f53f70621c6c58ca4a3c4d3434205e608e121b5b3b71f4f3"
],
"index": "pypi",
"version": "==19.8.1"
"version": "==19.9.0"
},
"itsdangerous": {
"hashes": [
@ -188,9 +200,9 @@
},
"sqlalchemy": {
"hashes": [
"sha256:2d5f08f714a886a1382c18be501e614bce50d362384dc089474019ce0768151c"
"sha256:72325e67fb85f6e9ad304c603d83626d1df684fdf0c7ab1f0352e71feeab69d8"
],
"version": "==1.2.8"
"version": "==1.2.10"
},
"werkzeug": {
"hashes": [

35
README.md Normal file
View File

@ -0,0 +1,35 @@
# Share
because ftp was too easy
## Quickstart
It's easy peasy my dude
1. Install pip and pipenv
```bash
apt install pip3
pip3 install pipenv
```
2. Get dependencies
```bash
pipenv Install
```
3. Initialize
```bash
pipenv run python setup.py serve_dir [--secret SECRET_KEY] [--db CONNECTION_STRING]
```
4. Run it
+ For testing
```bash
pipenv shell
FLASK_APP="notpiracyiswear.py" flask run
```
+ For production
```bash
pipenv run gunicorn notpiracyiswear:app
```

View File

@ -8,7 +8,7 @@ import os
from models import db, User, Referal
app = Flask(__name__)
app.config.from_pyfile('settings.cfg')
app.config.from_json('config.json')
db.app = app
db.init_app(app)

View File

@ -1,4 +0,0 @@
DEBUG = True
SECRET_KEY = "badkeyplsremove"
SQLALCHEMY_DATABASE_URI = 'sqlite:///test.db'
SQLALCHEMY_TRACK_MODIFICATIONS = False

30
setup.py Normal file
View File

@ -0,0 +1,30 @@
from models import User
from alembic import command
import json
import secrets
import click
@click.command()
@click.argument("serve_dir")
@click.option('--secret', help="Secret key to use. A random hex string will be generated if not provided")
@click.option('--db', 'connection', help="Database connection string. Defaults to \"sqlite:///test.db\"")
def main(serve_dir, secret=None, connection=None):
config = {"serve_dir": serve_dir, "SECRET_KEY": secret or secrets.token_hex(), "SQLALCHEMY_DATABASE_URI": connection or 'sqlite:///test.db'}
with open('config.json', 'w') as f:
json.dump(config, f, indent=2)
# HACK: this is probably not the best way to make sure the built config is applied before we do anything else
from notpiracyiswear import app, db, migrate
db.create_all()
admin = User('admin', app.config['SECRET_KEY'])
db.session.add(admin)
db.session.commit()
config = migrate.get_config()
with app.app_context():
command.stamp(config, 'head', sql=False, tag=None)
if __name__ == '__main__':
main()