Merge client and server in a single bottle app
2
.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
*.swp
|
||||||
|
*.pyc
|
|
@ -5,10 +5,10 @@
|
||||||
|
|
||||||
<title> TechREC </title>
|
<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 src="/static/js/jquery-1.9.1.min.js"></script>
|
||||||
<script type="text/javascript" src="js/reclibrary.js"></script>
|
<script type="text/javascript" src="/static/js/reclibrary.js"></script>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
/*
|
/*
|
4
server/requirements.txt
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
PyYAML==3.10
|
||||||
|
SQLAlchemy==0.8.3
|
||||||
|
bottle==0.11.6
|
||||||
|
wsgiref==0.1.2
|
|
@ -1,9 +1,10 @@
|
||||||
# from bottle import hook, response, route, run, static_file, request
|
# from bottle import hook, response, route, run, static_file, request
|
||||||
from bottle import Bottle, hook, template, response, request,static_file
|
import datetime
|
||||||
import json
|
import logging
|
||||||
import socket
|
|
||||||
|
|
||||||
from techrec import *
|
from bottle import Bottle, hook, response, request,static_file
|
||||||
|
|
||||||
|
from techrec import Rec, RecDB
|
||||||
|
|
||||||
class RecServer:
|
class RecServer:
|
||||||
def __init__(self,host="127.0.0.1", port=8000):
|
def __init__(self,host="127.0.0.1", port=8000):
|
||||||
|
@ -16,7 +17,7 @@ class RecServer:
|
||||||
self.db = RecDB()
|
self.db = RecDB()
|
||||||
|
|
||||||
def start(self):
|
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')
|
@hook('after_request')
|
||||||
def enable_cors(self):
|
def enable_cors(self):
|
||||||
|
@ -35,11 +36,20 @@ class RecServer:
|
||||||
# self._app.post('/create', callback=self.create)
|
# self._app.post('/create', callback=self.create)
|
||||||
|
|
||||||
self._app.route('/update', method="POST", callback=self.update)
|
self._app.route('/update', method="POST", callback=self.update)
|
||||||
|
|
||||||
self._app.route('/search', method="POST", callback=self.search)
|
self._app.route('/search', method="POST", callback=self.search)
|
||||||
|
|
||||||
self._app.route('/delete', method="POST", callback=self.delete)
|
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 ):
|
def extsearch( self, args ):
|
||||||
print "ARG", args
|
print "ARG", args
|
||||||
|
@ -164,7 +174,7 @@ class RecServer:
|
||||||
|
|
||||||
# @route('/favicon.ico')
|
# @route('/favicon.ico')
|
||||||
def favicon(self):
|
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')
|
# @route('/help')
|
||||||
def help(self):
|
def help(self):
|
||||||
|
@ -184,5 +194,5 @@ class RecServer:
|
||||||
TESTs
|
TESTs
|
||||||
"""
|
"""
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
c = RecServer(host="0.0.0.0")
|
c = RecServer(host="localhost")
|
||||||
c.start()
|
c.start()
|
||||||
|
|
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 18 KiB |
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
Before Width: | Height: | Size: 673 B After Width: | Height: | Size: 673 B |
Before Width: | Height: | Size: 2.8 KiB After Width: | Height: | Size: 2.8 KiB |
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 2.2 KiB |