Procházet zdrojové kódy

API 두 개 추가

Surplus_Up (2DU) před 8 roky
rodič
revize
08a0fdd79c
1 změnil soubory, kde provedl 26 přidání a 2 odebrání
  1. 26 2
      app.py

+ 26 - 2
app.py

@@ -729,7 +729,8 @@ def setting(num = 0):
                             <input placeholder="reCAPTCHA (Secret Key)" type="text" name="sec_re" value="''' + html.escape(d_list[1]) + '''">
                             <hr>
                             <button id="save" type="submit">''' + load_lang('save') + '''</button>
-                        </form>''',
+                        </form>
+                        ''',
                 menu = [['setting', load_lang('setting')]]
             ))
     else:
@@ -1549,7 +1550,8 @@ def set_edit_filter(name = None):
                         <input ''' + stat + ''' placeholder="Regex" name="content" value="''' + html.escape(textarea) + '''" type="text">
                         <hr>
                         <button ''' + stat + ''' id="save" type="submit">''' + load_lang('save') + '''</button>
-                    </form>''',
+                    </form>
+                    ''',
             menu = [['edit_filter', load_lang('list')], ['edit_filter/' + url_pas(name) + '/delete', load_lang('delete')]]
         ))
 
@@ -3722,6 +3724,28 @@ def skin_set():
         menu = 0
     ))
     
+@app.route('/api/w/<path:name>')
+def api_w(name = None):
+    curs.execute("select data from data where title = ?", [name])
+    data = curs.fetchall()
+    if data:
+        json_data = { "title" : name, "data" : namumark(data = data[0][0]) }
+    
+        return flask.jsonify(json_data)
+    else:
+        return redirect('/')
+    
+@app.route('/api/raw/<path:name>')
+def api_raw(name = None):
+    curs.execute("select data from data where title = ?", [name])
+    data = curs.fetchall()
+    if data:
+        json_data = { "title" : name, "data" : data[0][0] }
+    
+        return flask.jsonify(json_data)
+    else:
+        return redirect('/')
+    
 @app.route('/views/<path:name>')
 def views(name = None):
     if re.search('\/', name):