Skip to content

Commit

Permalink
feat(doc): Add copyright and license information (#38)
Browse files Browse the repository at this point in the history
Co-authored-by: Glen Whitney <glen@studioinfinity.org>
  • Loading branch information
Liam Mulhall and gwhitney authored May 28, 2022
1 parent e856712 commit aeb7595
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 40 deletions.
18 changes: 18 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
Copyright 2020-2022 Regents of the University of Colorado

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
57 changes: 17 additions & 40 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# NumberscopeFlask

Copyright 2020-2022 Regents of the University of Colorado.

This project is licensed under the
[MIT License](https://opensource.org/licenses/MIT). See the text of the MIT
License in LICENSE.md.

## Initial Setup

Expand All @@ -14,7 +18,7 @@ You will need:

Set up initial dependencies:

1. Source / create your python environment:
1. Source / create your python environment:

```bash
$ virtualenv -p python3 .venv # Create a new virtual env called .venv
Expand Down Expand Up @@ -83,22 +87,20 @@ Set up initial dependencies:
$ # alembic.ini, which is safe to ignore - the default works fine
$ python3 manage.py db migrate # migrate data models found in the project to database
$ python3 manage.py db upgrade # Upgrade changes to database

$ psql -d <database_name>
db=# \d
Schema | Name | Type | Owner
db=# \d
Schema | Name | Type | Owner
--------+-----------------+----------+-------
public | alembic_version | table | theo
public | user | table | theo
public | user_id_seq | sequence | theo

db=# \q
```

Currently there is one example user model in flaskr/nscope/models.py



### Running the application

---
Expand Down Expand Up @@ -224,13 +226,13 @@ An array of strings giving all OEIS ids that mention the given OEIS_ID.

### URL: `api/get_oeis_factors/<OEIS_ID>/<COUNT>`

This could take a long time. It internally does everything that the endpoint
This could take a long time. It internally does everything that the endpoint
`get_oeis_metadata` does, and then once the result is stored in the database
it proceeds to factor the first `<COUNT>` terms of the sequence (or all of them
if there are not that many). If you are running the server to test it on your
local host, a full URL would be
`http://127.0.0.1:5000/api/get_oeis_factors/A006862/50` which will return the
factorizations of 1 + the product of the first n primes, for n < 50. The
factorizations of 1 + the product of the first n primes, for n < 50. The
first 42 terms will be factored and larger terms will return `no_fac` (since
they are deemed too large to factor in a reasonable time).

Expand All @@ -249,10 +251,10 @@ The format of each entry is a string of the form

`[[p,e],[q,f],...]`

where each entry `[p,e]` represents a factor of the prime p to the power e. If
an integer is negative, `[-1,1]` is included. If the integer is 1, the
factorization is `[]` (empty). If the integer is 0, the factorization
is `[[0,1]]`. Any successful factorization has the property that if you
where each entry `[p,e]` represents a factor of the prime p to the power e. If
an integer is negative, `[-1,1]` is included. If the integer is 1, the
factorization is `[]` (empty). If the integer is 0, the factorization
is `[[0,1]]`. Any successful factorization has the property that if you
multiply 1 times the product of `p^e` for all `[p,e]` in the array, you
obtain the original value. This format is essentially that supported by pari.
If the integer exceeds 2^200, the factorization is not attempted and
Expand Down Expand Up @@ -290,77 +292,52 @@ The log file for the flask application

an example logging statment is shown below in python3

``` python3
```python3
app.logger.info('%s logged in successfully', user.username)
```

Logging levels are set in flaskr/config.py

Refer to https://flask.palletsprojects.com/en/1.1.x/logging/ for more information



##### flaskr

Flaskr is the main application. It contains all entry points to the application. \__init\__.py contains all the application macros.


Flaskr is the main application. It contains all entry points to the application. \_\_init\_\_.py contains all the application macros.

##### flaskr/\_\_init\_\_.py

The primary file for all application macros



##### flaskr/config.py

The configuration directory for all macro config options. Generally development mode is being used.



##### flaskr/nscope

The nscope api python module. This contains numberscope endpoints and blueprints and models



##### flaskr/nscope/\_\_init\_\_.py

The main entry point to nscope, containing the blueprint for numberscope (imported in \_\_init\_\_.py in flaskr)



##### flaskr/nscope/models.py

Database models. See the example for how to define models as well as https://flask-sqlalchemy.palletsprojects.com/en/2.x/models/



##### flaskr/nscope/views.py

The primary blueprint for numberscope. This is the main application. Note that currently, there is only one endpoint (vuetest). But refer to the documentation within views on how to create a new route.





### WSGI Setup

WSGI is setup on the production server. all wsgi instances and configurations are neglected in the github repository for security.

Documentation is in progress.



On the server, you may manage the status of the application by the systemd entry point for numberscope



```bash
$ sudo systemctl status numberscopeFlask.service
```



Numberscope is serving both index.html as well as the numberscope api routes declared inside flask.

10 changes: 10 additions & 0 deletions manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"""

import os
import sys

from flask_script import Manager
from flask_migrate import Migrate, MigrateCommand
Expand All @@ -17,5 +18,14 @@
manager.add_command('db', MigrateCommand)

if __name__ == '__main__':
if sys.argv[1] == 'runserver':
print('''
Copyright 2020-2022 Regents of the University of Colorado.
This project is licensed under the
[MIT License](https://opensource.org/licenses/MIT). See LICENSE.md.
''')
manager.run()

0 comments on commit aeb7595

Please sign in to comment.