Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a282072
commit 9cc50bb
Showing
3 changed files
with
129 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
#!/usr/bin/python | ||
# -*- coding:utf-8 -*- | ||
from string import Template | ||
|
||
|
||
app_init = Template(""" | ||
#!/usr/bin/python | ||
# -*- coding:utf-8 -*- | ||
import falcon | ||
# from .middleware import * | ||
from .resources import ${module_title}Resource | ||
${module}Resource = ${module_title}Resource() | ||
def create_app(): | ||
app = falcon.API(middleware=[]) | ||
app.add_route('/', ${module}Resource) | ||
return app | ||
""".strip()) | ||
|
||
|
||
manager = """ | ||
#!/usr/bin/python | ||
# -*- coding: utf-8 -*- | ||
from wsgiref import simple_server | ||
from app import create_app | ||
# Set up falcon api | ||
app = application = create_app() | ||
if __name__ == '__main__': | ||
httpd = simple_server.make_server('127.0.0.1', 5000, app) | ||
httpd.serve_forever() | ||
""".strip() | ||
|
||
|
||
resource_init = Template(""" | ||
#!/usr/bin/python | ||
# -*- coding:utf-8 -*- | ||
from .${module} import ${module_title}Resource | ||
""".strip()) | ||
|
||
|
||
resource_controller = Template(""" | ||
#!/usr/bin/python | ||
# -*- coding:utf-8 -*- | ||
import falcon | ||
class ${module_title}Resource(object): | ||
def __init__(self): | ||
pass | ||
def on_get(self, req, resp): | ||
resp.status = falcon.HTTP_200 | ||
resp.body = 'Server works!' | ||
def on_post(self, req, resp): | ||
resp.status = falcon.HTTP_200 | ||
resp.body = 'Server works!' | ||
""".strip()) | ||
|
||
|
||
requirements = """ | ||
falcon | ||
""".strip() |