-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.py
39 lines (33 loc) · 1.14 KB
/
server.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
from bottle import Bottle, route, run, view, get, post, request, static_file, template, debug
from rsseditor import RssEditor
from rsseditor import FeedLoader
import os
from pprint import pprint
app = Bottle()
debug(True)
@app.route('/static/js/:filename')
def send_static(filename):
return static_file(filename, root='./static/js')
@app.route('/')
@view('main.tpl')
def main():
return {}
@app.post('/loadFeed')
def loadFeed():
feedUrl = request.forms.get('feedUrl')
feedLoader = FeedLoader()
index = feedLoader.add(feedUrl)
editor = RssEditor(feedLoader)
(feedTitle, feedItems) = editor.renderFeed()
return template('feed', title=feedTitle, itemList=feedItems, feedKey=index)
@app.post('/editFeedValue/:index')
def editFeedValue(index):
path = request.forms.get('path')
value = request.forms.get('value')
feedLoader = FeedLoader(int(index))
editor = RssEditor(feedLoader)
for key in request.forms:
editor.edit(key, request.forms[key])
(feedTitle, feedItems) = editor.renderFeed()
return template('feed', title=feedTitle, itemList=feedItems, feedKey=index)
run(app, host='localhost', port=8080)