Merge client and server in a single bottle app

This commit is contained in:
boyska 2013-11-26 12:04:43 +01:00
parent beba17e871
commit 36eae35528
17 changed files with 71 additions and 55 deletions

2
.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
*.swp
*.pyc

View file

@ -5,10 +5,10 @@
<title> TechREC </title>
<link rel="stylesheet" type="text/css" href="css/style.css">
<link rel="stylesheet" type="text/css" href="/static/css/style.css">
<script src="js/jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="js/reclibrary.js"></script>
<script src="/static/js/jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="/static/js/reclibrary.js"></script>
<script>
/*

4
server/requirements.txt Normal file
View file

@ -0,0 +1,4 @@
PyYAML==3.10
SQLAlchemy==0.8.3
bottle==0.11.6
wsgiref==0.1.2

View file

@ -1,9 +1,10 @@
# from bottle import hook, response, route, run, static_file, request
from bottle import Bottle, hook, template, response, request,static_file
import json
import socket
import datetime
import logging
from techrec import *
from bottle import Bottle, hook, response, request,static_file
from techrec import Rec, RecDB
class RecServer:
def __init__(self,host="127.0.0.1", port=8000):
@ -16,7 +17,7 @@ class RecServer:
self.db = RecDB()
def start(self):
self._app.run(host=self._host, port=self._port)
self._app.run(host=self._host, port=self._port, debug=True)
@hook('after_request')
def enable_cors(self):
@ -35,11 +36,20 @@ class RecServer:
# self._app.post('/create', callback=self.create)
self._app.route('/update', method="POST", callback=self.update)
self._app.route('/search', method="POST", callback=self.search)
self._app.route('/delete', method="POST", callback=self.delete)
self._app.route('/static/<filepath:path>',
callback= lambda filepath: static_file(filepath, root='static/'))
self._app.route('/js/<f>',
callback= lambda f: static_file(f, root='static/js/'))
self._app.route('/css/<f>',
callback= lambda f: static_file(f, root='static/css/'))
self._app.route('/img/<f>',
callback= lambda f: static_file(f, root='static/img/'))
self._app.route('/', callback=lambda: static_file('index.html',
root='pages/'))
self._app.route('/tempo', callback=lambda: static_file('tempo.html',
root='pages/'))
def extsearch( self, args ):
print "ARG", args
@ -164,7 +174,7 @@ class RecServer:
# @route('/favicon.ico')
def favicon(self):
return static_file('icon.ico', root="./img/", mimetype="image/ico")
return static_file('icon.ico', root="/static/img/", mimetype="image/ico")
# @route('/help')
def help(self):
@ -184,5 +194,5 @@ class RecServer:
TESTs
"""
if __name__ == "__main__":
c = RecServer(host="0.0.0.0")
c = RecServer(host="localhost")
c.start()

View file

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 18 KiB

View file

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB

View file

Before

Width:  |  Height:  |  Size: 673 B

After

Width:  |  Height:  |  Size: 673 B

View file

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 2.8 KiB

View file

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB