-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgoal.py
47 lines (33 loc) · 1.07 KB
/
goal.py
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
from fastpyservers import AsyncWebApp
from fastpyservers.requests import methods
from fastpyservers.responses import field, json
app = AsyncWebApp('v1')
app.queue([
{"task": "Task 1", "on": field.datetime('')},
{"task": "Task 2", "on": field.datetime('')},
{"task": "Task 3", "on": field.datetime('')}
])
app.model("users": {
"first_name": field.string(1, 60),
"last_name": field.string(1, 100),
"age": field.integer(>, 18),
"birthday": field.datetime(''),
"stocks": [
{
"price": field.price(USD),
"ticker_name": field.string(=, 3)
}
]
})
app.handler(model, methods['POST'], json) ## will return http://0.0.0.0:8080/users/?first_name=Shawn&last_name=Needz
app.handler('/queue', methods['GET','POST'], json)
if __name__ == '__main__':
app.run()
## Route handlers elder version
async def router_handler(route, method, content_type, body):
Response(body=body, content_type
## Error Handler
async def handle_method_error():
Response(body='Method not allowed for URL', status=405)
async def handle_method_error():
Response(body='URL not found', status=404)