Compare commits
No commits in common. "32dcf0c4a464125f3521f18e2cf6e0e524b96d22" and "3599e80e7737e7b464433b7749a0e4a99c6b66ac" have entirely different histories.
32dcf0c4a4
...
3599e80e77
@ -1,92 +0,0 @@
|
|||||||
Getting started
|
|
||||||
===============
|
|
||||||
|
|
||||||
.. note::
|
|
||||||
|
|
||||||
Currently, Sachet does not have the configs to run under WSGI for production yet.
|
|
||||||
This page only explains how to get Sachet up and running for development purposes.
|
|
||||||
|
|
||||||
Installation
|
|
||||||
------------
|
|
||||||
Clone the repo::
|
|
||||||
|
|
||||||
git clone https://github.com/dogeystamp/sachet-server
|
|
||||||
cd sachet-server
|
|
||||||
|
|
||||||
Create a venv with required dependencies::
|
|
||||||
|
|
||||||
python -m venv venv
|
|
||||||
source venv/bin/activate
|
|
||||||
python -m pip install -r requirements.txt
|
|
||||||
|
|
||||||
Create a configuration file::
|
|
||||||
|
|
||||||
cp config.yml.example config.yml
|
|
||||||
|
|
||||||
Remember to set up a secret key in ``config.yml``:
|
|
||||||
|
|
||||||
.. code-block:: yaml
|
|
||||||
|
|
||||||
SECRET_KEY: "41DJjqp6+Ztk9krJkwbZem1+JijowDU6ifkgdntF2FK3ygi5HM"
|
|
||||||
|
|
||||||
.. note::
|
|
||||||
|
|
||||||
You can generate a secret key using the following command on Linux::
|
|
||||||
|
|
||||||
cat /dev/urandom | base64 | head -c 50
|
|
||||||
|
|
||||||
.. warning::
|
|
||||||
|
|
||||||
Keep this secret key safe!
|
|
||||||
If you leak this key, a malicious attacker could authenticate as any user on your server.
|
|
||||||
|
|
||||||
Initialize the database::
|
|
||||||
|
|
||||||
flask --debug --app sachet.server db upgrade
|
|
||||||
|
|
||||||
Set up an administrator user::
|
|
||||||
|
|
||||||
flask --debug --app sachet.server user create --username admin --admin yes --password password123
|
|
||||||
|
|
||||||
.. warning::
|
|
||||||
|
|
||||||
Setting the password via the command-line is not safe.
|
|
||||||
In a real environment, you should reset this password immediately (see :ref:`authentication_password_change`.)
|
|
||||||
|
|
||||||
You can now start Sachet in development mode::
|
|
||||||
|
|
||||||
flask --debug --app sachet.server run
|
|
||||||
|
|
||||||
Development
|
|
||||||
-----------
|
|
||||||
|
|
||||||
.. note::
|
|
||||||
|
|
||||||
This section also requires being in the virtual environment::
|
|
||||||
|
|
||||||
source venv/bin/activate
|
|
||||||
|
|
||||||
Testing
|
|
||||||
^^^^^^^
|
|
||||||
|
|
||||||
You can run tests using pytest::
|
|
||||||
|
|
||||||
pytest --cov --cov-report term-missing
|
|
||||||
|
|
||||||
Linting
|
|
||||||
^^^^^^^
|
|
||||||
|
|
||||||
Please use the linter before submitting code::
|
|
||||||
|
|
||||||
black .
|
|
||||||
|
|
||||||
Database maintenance
|
|
||||||
--------------------
|
|
||||||
|
|
||||||
To clean up the database (remove stale entries)::
|
|
||||||
|
|
||||||
flask --app sachet.server cleanup
|
|
||||||
|
|
||||||
Otherwise, to upgrade the database after a schema change::
|
|
||||||
|
|
||||||
flask --app sachet.server db upgrade
|
|
@ -10,7 +10,6 @@ Welcome to Sachet's documentation!
|
|||||||
:maxdepth: 2
|
:maxdepth: 2
|
||||||
:caption: Contents:
|
:caption: Contents:
|
||||||
|
|
||||||
getting_started
|
|
||||||
authentication
|
authentication
|
||||||
pagination
|
pagination
|
||||||
permissions
|
permissions
|
||||||
@ -20,6 +19,56 @@ Welcome to Sachet's documentation!
|
|||||||
|
|
||||||
Sachet is a small file-sharing server.
|
Sachet is a small file-sharing server.
|
||||||
|
|
||||||
|
development
|
||||||
|
-----------
|
||||||
|
|
||||||
|
To start sachet in dev mode:
|
||||||
|
|
||||||
|
Clone the repo::
|
||||||
|
|
||||||
|
git clone https://github.com/dogeystamp/sachet
|
||||||
|
cd sachet
|
||||||
|
|
||||||
|
Create a venv with required dependencies::
|
||||||
|
|
||||||
|
python -m venv venv
|
||||||
|
source venv/bin/activate
|
||||||
|
python -m pip3 install -r requirements.txt
|
||||||
|
|
||||||
|
Create a configuration file (and set the secret key!)::
|
||||||
|
|
||||||
|
cp config.yml.example config.yml
|
||||||
|
vim config.yml
|
||||||
|
|
||||||
|
Start Flask in development mode::
|
||||||
|
|
||||||
|
flask --debug --app sachet.server run
|
||||||
|
|
||||||
|
tests
|
||||||
|
^^^^^
|
||||||
|
|
||||||
|
Run tests with pytest::
|
||||||
|
|
||||||
|
pytest --cov --cov-report term-missing
|
||||||
|
|
||||||
|
linting
|
||||||
|
^^^^^^^
|
||||||
|
|
||||||
|
Please use the linter before submitting code::
|
||||||
|
|
||||||
|
black .
|
||||||
|
|
||||||
|
database maintenance
|
||||||
|
--------------------
|
||||||
|
|
||||||
|
To clean up the database (remove stale entries)::
|
||||||
|
|
||||||
|
flask --app sachet.server cleanup
|
||||||
|
|
||||||
|
Otherwise, to upgrade the database after a schema change::
|
||||||
|
|
||||||
|
flask --app sachet.server db upgrade
|
||||||
|
|
||||||
Indices and tables
|
Indices and tables
|
||||||
==================
|
==================
|
||||||
|
|
||||||
|
@ -89,13 +89,9 @@ class User(db.Model):
|
|||||||
|
|
||||||
self.password = self.gen_hash(password)
|
self.password = self.gen_hash(password)
|
||||||
self.username = username
|
self.username = username
|
||||||
|
self.url = url_for("users_blueprint.user_api", username=self.username)
|
||||||
self.register_date = datetime.datetime.now()
|
self.register_date = datetime.datetime.now()
|
||||||
|
|
||||||
@property
|
|
||||||
def url(self):
|
|
||||||
"""URL linking to this resource."""
|
|
||||||
return url_for("users_blueprint.user_api", username=self.username)
|
|
||||||
|
|
||||||
def gen_hash(self, psswd):
|
def gen_hash(self, psswd):
|
||||||
"""Generates a hash from a password."""
|
"""Generates a hash from a password."""
|
||||||
return bcrypt.generate_password_hash(
|
return bcrypt.generate_password_hash(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user