-
Notifications
You must be signed in to change notification settings - Fork 0
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
b696637
commit 8129c20
Showing
1 changed file
with
44 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
from flask import Flask,request | ||
import jinja2 | ||
|
||
import importlib | ||
|
||
import sys | ||
#import conf | ||
|
||
theme = 'goodold' | ||
path = '/home/streetartist' | ||
|
||
sys.path.append(path+"/plugins/") | ||
|
||
app = Flask(__name__) | ||
|
||
import plugins.dispose | ||
|
||
env = jinja2.Environment(loader=jinja2.FileSystemLoader(path+'/theme/'+theme)) | ||
|
||
def use_plugin(plugin,using,request=""): | ||
if using=="": | ||
return plugin.main() | ||
elif plugin.get_name() == using: | ||
return plugin.main(request) | ||
else: | ||
return plugin.main() | ||
|
||
env.filters['use_plugin'] = use_plugin # 注册自定义过滤器 | ||
|
||
@app.route('/') | ||
@app.route('/<using>',methods=['GET','POST']) | ||
def myindex(using=""): | ||
# Event Index_start | ||
the_plugins = plugins.dispose.Index_start() | ||
index_temp = env.get_template('index.html') | ||
if request.method=="POST": | ||
return index_temp.render(hi="你好", plugins=the_plugins, request=request,using=using) | ||
else: | ||
return index_temp.render(hi="你好",plugins=the_plugins, request="",using=using) | ||
|
||
@app.route('/plugins/<name>') | ||
def the_plugins(name): | ||
plugin = importlib.import_module('plugins.'+name).Main() | ||
return plugin.main() |