-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME.txt
56 lines (38 loc) · 1.99 KB
/
README.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
This project is a small application which has one page that takes a number n
in range 1-100. The service will return:
- a value calculated from the difference of the square of the sum of all
natural numbers 1-n and the sum of the squares of all numbers 1-n
- the number of times this number has been input to the system
- the time of request
1. Setup
From your virtualenv, install packages via pip:
- pip install -r requirements.txt
Next, open config.py and put your postgresql user's username and password
in Config.PG_USER and Config.PG_PASSWORD respectively.
Then, to create the database and the testing database, and insert our model
into the database (note this would go in a dedicated script in a larger
structured project)
- python models.py
2. Running the application
To start, simply run
- python run.py
Then for a number n between 1 and 100, navigate on your browser to
localhost:8000/difference?number=[n goes here]. Other numbers, non-numbers,
and blank values will return an error message and code.
3. Testing
nosetests :)
Be sure you haven't dropped the testing database.
4. Next steps for project
- A frontend. I was looking to build a simple AngularJS UI which would display
the value upon inputting a number, but did not have the time
- Find a better database session, closer to ZopeTransactionManager. My only
view uses db.session.commit(), which is something that can cause conflict if
an external function also tries to commit, and can be forgotten. Depending on setup,
it could cause a problem with the test database, if anything besides basic
tables (triggers, functions, views) are needed for the test database to run
correctly (current setup implies they are not)
A decorator could be a solution, but needs to be sure it doesn't commit bad data.
- Structured directories. I'm new to flask and couldn't quite figure out how
to structure the files outside of a flat directory and make the imports work
correctly without having to install the app as a package (maybe that's the
solution?)