Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,30 +15,30 @@ To set up a racket Webserver with API landing points that interpret JSON input,
| 2 | Allow for multiple landing pages associated to the API methods | done |
|2.1| Web API Documentation | done |
|2.2| Generate proof of success| done |
| 3 | Create a JSON processor object | started |
|3.1| JSON object Documentation | not started |
|3.2| Generate proof of success| not started |
| 3 | Create a JSON processor object | replaced - param handler class |
|3.1| JSON object Documentation | skipped |
|3.2| Generate proof of success| skipped |
| 4 | Create a Server API Handler object | done |
|4.1| Server API handler Documentation | done |
|4.2| Generate proof of success| not-started |
| 5 | Create a Mathematics object | not started |
|5.1| Mathematics object Documentation | not started |
|5.2| Generate proof of success| not started |
| 5 | Create a Mathematics object | done |
|5.1| Mathematics object Documentation | done |
|5.2| Generate proof of success| done |
| 6 | Create a Graphing object | not started |
|6.1| Graphing object Documentation | not started |
|6.2| Generate proof of success| not started |
|7 | Integrate objects | not started |
|7.1| Generate proof of success| not started |
|7 | Integrate objects | done |
|7.1| Generate proof of success| done |

### First Milestone Goals (04-13)
During the First Milestone we will have turned in Client related items (Items 1 - 2.2) as well as the Mathematics portion (Items 5 - 5.2)
### Second Milestone Goals
Items 3 - 4.2 , 6.1 - 7.1

## Group Responsibilities
### Jose Flores
Will be responsible for the transmission and interpretation of data, so will be primarily working with (Items 1 - 4.2)
Will be working with a parameter handler and integrating the application (Item 3 - 4.2 , 6.1 - 7.1 )

### Munkhjargal Narmandakh
Will be responsible for the production of results, so will be focusing on (Items 5 - 6.2)
Will be responsible for the the Graphing object (Items 6 - 6.2)

### Results & Documentation
Documentation can be found in wolfracket/documentation.md
Expand Down
50 changes: 50 additions & 0 deletions tmp.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# FP7-webpage Title of Project

##Authors
Jose Flores

Munkhjargal Narmandakh

##Overview
To set up a racket Webserver with API landing points that interpret JSON input, which would then be processed by Racket to evaluated solutions. These solutions would then be returned by the webserver and in JSON form, images would be returned as links.

##Screenshot
(insert a screenshot here. You may opt to get rid of the title for it. You need at least one screenshot. Make it actually appear here, don't just add a link.)

Here's a demonstration of how to display an image that's uploaded to this repo:
![screenshot showing env diagram](withdraw.png)

##Concepts Demonstrated
Identify the OPL concepts demonstrated in your project. Be brief. A simple list and example is sufficient.
* **Data abstraction** is used to provide access to the elements of the RSS feed.
* The objects in the OpenGL world are represented with **recursive data structures.**
* **Symbolic language processing techniques** are used in the parser.

##External Technology and Libraries
Briefly describe the existing technology you utilized, and how you used it. Provide a link to that technology(ies).

##Favorite Lines of Code
####Mark (a team member)
Each team member should identify a favorite line of code, expression, or procedure written by them, and explain what it does. Why is it your favorite? What OPL philosophy does it embody?
Remember code looks something like this:
```scheme
(map (lambda (x) (foldr compose functions)) data)
```
####Lillian (another team member)
This expression reads in a regular expression and elegantly matches it against a pre-existing hashmap....
```scheme
(let* ((expr (convert-to-regexp (read-line my-in-port)))
(matches (flatten
(hash-map *words*
(lambda (key value)
(if (regexp-match expr key) key '()))))))
matches)
```

##Additional Remarks
Anything else you want to say in your report. Can rename or remove this section.

#How to Download and Run
You may want to link to your latest release for easy downloading by people (such as Mark).

Include what file to run, what to do with that file, how to interact with the app when its running, etc.
25 changes: 25 additions & 0 deletions wolfracket/documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,28 @@ generated by the server-handler class.

## json.rkt
In progress.

### math.rkt

This is our custom math operations library, current operations allowed are...

| method | params | returns|
|--------|--------|--------|
|'subtract| a b | a - b|
|'add | a b | a + b|
|'exponent| a b | a ^ b|
|'divide| a b | a / b|
|'prime_check| a | #t or #f |
|'nat-log| a b | a - b|
|'factorials| a | a! |
|'sinus| a | sin( a )|
|'cosh| a | cos( a )|
|'root| a | a ^ (1/2) |

To use the class

```
(((my_math) method) params ...)
```

where method are the operations allowed by the class and params are the needed parameters for the operation.
82 changes: 70 additions & 12 deletions wolfracket/lib/api.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@
; This file holds the api.

; REQUIRES
(require web-server/servlet
(require racket/include
web-server/servlet
web-server/servlet-env)

(include "param-handler.rkt")
(include "math.rkt")

; @name api
;
; The api recieves requests from the server-handler and processes them through
Expand All @@ -23,32 +27,86 @@
; @return json the calculated output or error message
(define (api)



; RESPONSES
; The api documentation page
; The API Documentation page
(define (api-home req)
(response/xexpr
`(html (head (title "API"))
(body (p "Racket Mathematics and Graphing API Project Documentation Page")))))

; The addition api method
; API Function Execution
(define (api-func method param min-param req)
(response/xexpr
#:mime-type #"application/json"
(string-join (list "["
(((param-handler) "list->string" )
(if (param-count? min-param (((param-handler) "string->list") req
param))
(((my_math) method) (((param-handler) "string->list") req
param))
(list "\"error\"")))
"]")
"")))

(define (param-count? min-param lst)
(>= (length lst) min-param))

; The API Methods
(define (api-add req)
(response/xexpr
`(html (head (title "ADD"))
(body (p "Addition method")))))
(api-func "add" "j" 2 req))

(define (api-subtract req)
(api-func "subtract" "j" 2 req))

(define (api-exponent req)
(api-func "exponent" "j" 2 req))

(define (api-divide req)
(api-func "divide" "j" 2 req))

(define (api-prime req)
(api-func "prime" "j" 1 req))

(define (api-logarithm req)
(api-func "logarithm" "j" 1 req))

(define (api-factorial req)
(api-func "factorial" "j" 1 req))

(define (api-sin req)
(api-func "sin" "j" 1 req))

(define (api-cos req)
(api-func "cos" "j" 1 req))

(define (api-sqrt req)
(api-func "sqrt" "j" 1 req))


; The method not found page
; The Method not found page
(define (api-404 req)
(response/xexpr
`(html (head (title "404"))
(body (p "API Resource not found.")))))

; CONTROLLER
; Delegates which method to call
(define (controller m)
(begin (display m)
(cond ((equal? m "home") api-home)
((equal? m "add") api-add)
(else api-404))))
(define (controller action p)
(begin ;(set! msg m)
(cond ((equal? action "home") api-home)
((equal? action "add") api-add)
((equal? action "subtract") api-subtract)
((equal? action "exponent") api-exponent)
((equal? action "divide") api-divide)
((equal? action "prime") api-prime)
((equal? action "logarithm") api-logarithm)
((equal? action "factorial") api-factorial)
((equal? action "sin") api-sin)
((equal? action "cos") api-cos)
((equal? action "sqrt") api-sqrt)
(else api-404))))

controller)

Expand Down
3 changes: 3 additions & 0 deletions wolfracket/lib/driver.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,6 @@
((server-handler) 'start)





43 changes: 43 additions & 0 deletions wolfracket/lib/htdocs/css/main.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
html, body {
margin: 0px;
padding: 0px;
font-family: helvetica;
}
div.header {
width: 100%;
height: 50px;
float:left;
background: #000;
box-shadow:1px 1px 1px #333;
}
div.title {
color:#fff;
font-size: 30px;
padding-left: 10px;
line-height: 50px;
float:left;
}
div.menu ul {
list-style-type: none;
float:left;
}
div.menu ul li {
float:left;
}
div.menu ul li a {
padding: 10px;
text-decoration: none;
color: #fff;
}
div.menu ul li a:hover {
background: #333;
text-decoration: underline;
}
div.content {}
div.footer {}
img.logo {
height: 40px;
width: 40px;
margin: 5px 15px;
float:left;
}
43 changes: 43 additions & 0 deletions wolfracket/lib/htdocs/main.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
html, body {
margin: 0px;
padding: 0px;
font-family: helvetica;
}
div.header {
width: 100%;
height: 50px;
float:left;
background: #000;
box-shadow:1px 1px 1px #333;
}
div.title {
color:#fff;
font-size: 30px;
padding-left: 10px;
line-height: 50px;
float:left;
}
div.menu ul {
list-style-type: none;
float:left;
}
div.menu ul li {
float:left;
}
div.menu ul li a {
padding: 10px;
text-decoration: none;
color: #fff;
}
div.menu ul li a:hover {
background: #333;
text-decoration: underline;
}
div.content {}
div.footer {}
img.logo {
height: 40px;
width: 40px;
margin: 5px 15px;
float:left;
}
20 changes: 20 additions & 0 deletions wolfracket/lib/htdocs/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@

var mysubmit = function(){
var url = "localhost:8080/api/" ;

var method = $( "#method" ).value() ;
var num1 = $( "#num1" ).value() ;
var num2 = $( "#num2" ).value() ;
var num3 = $( "#num3" ).value() ;

var data = { "j" : [num1 , num2 , num3 ] } ;

$.ajax({
url: url + method + '/' ,
data: data
}).done( function( ret ) {
console.log( "done" ) ;
console.log( ret ) ;
$( "#result" ).html( ret ) ;
});
};
43 changes: 43 additions & 0 deletions wolfracket/lib/main.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
html, body {
margin: 0px;
padding: 0px;
font-family: helvetica;
}
div.header {
width: 100%;
height: 50px;
float:left;
background: #000;
box-shadow:1px 1px 1px #333;
}
div.title {
color:#fff;
font-size: 30px;
padding-left: 10px;
line-height: 50px;
float:left;
}
div.menu ul {
list-style-type: none;
float:left;
}
div.menu ul li {
float:left;
}
div.menu ul li a {
padding: 10px;
text-decoration: none;
color: #fff;
}
div.menu ul li a:hover {
background: #333;
text-decoration: underline;
}
div.content {}
div.footer {}
img.logo {
height: 40px;
width: 40px;
margin: 5px 15px;
float:left;
}
Loading