Bladeren bron

first with Go

잉여개발기 (SPDV) 3 jaren geleden
bovenliggende
commit
f3c626365b
7 gewijzigde bestanden met toevoegingen van 126 en 27 verwijderingen
  1. 15 0
      app.py
  2. 1 2
      readme-en.md
  3. 1 2
      readme.md
  4. 2 23
      route/main_func_easter_egg.py
  5. 32 0
      route_go/main_easter_egg.go
  6. 75 0
      route_go/main_easter_egg.h
  7. BIN
      route_go/main_easter_egg.so

+ 15 - 0
app.py

@@ -1,6 +1,7 @@
 # Init
 import os
 import re
+import ctypes
 
 from route.tool.func import *
 from route import *
@@ -638,6 +639,20 @@ app.route('/setting/skin_set', methods = ['POST', 'GET'])(main_setting_skin_set)
 
 app.route('/easter_egg')(main_func_easter_egg)
 
+def main_easter_egg_go():
+    with get_db_connect() as conn:
+        lib = ctypes.cdll.LoadLibrary('./route_go/main_easter_egg.so')
+        lib.Do.restype = ctypes.c_char_p
+
+        return easy_minify(flask.render_template(skin_check(),
+            imp = ['Easter Egg', wiki_set(), wiki_custom(), wiki_css([0, 0])],
+            data = str(lib.Do(), 'utf-8'),
+            menu = 0
+        ))
+
+app.route('/easter_egg_go')(main_easter_egg_go)
+
+
 # views -> view
 app.route('/view/<path:name>')(main_view)
 app.route('/views/<path:name>')(main_view)

+ 1 - 2
readme-en.md

@@ -1,8 +1,7 @@
 [(en-US)](./readme-en.md) | [(ko-KR)](./readme.md)
 
 # openNAMU
-[![Up to Python 3.7](https://img.shields.io/badge/python->=%203.7-blue.svg)](https://python.org)
-[![Up to PyPy 3.7](https://img.shields.io/badge/pypy3-%3E=%203.7-blue.svg)](https://www.pypy.org/)
+[![Up to Python 3.8](https://img.shields.io/badge/python->=%203.8-blue.svg)](https://python.org)
 [![LICENSE](https://img.shields.io/badge/license-BSD%203--Clause-lightgrey.svg)](./LICENSE)
 
 ![](https://raw.githubusercontent.com/openNAMU/openNAMU/beta/.github/logo.png)

+ 1 - 2
readme.md

@@ -1,8 +1,7 @@
 [(en-US)](./readme-en.md) | [(ko-KR)](./readme.md)
 
 # 오픈나무
-[![Python 3.7 이상](https://img.shields.io/badge/python->=%203.7-blue.svg)](https://python.org)
-[![PyPy 3.7 이상](https://img.shields.io/badge/pypy3-%3E=%203.7-blue.svg)](https://www.pypy.org/)
+[![Python 3.8 이상](https://img.shields.io/badge/python->=%203.8-blue.svg)](https://python.org)
 [![라이선스](https://img.shields.io/badge/license-BSD%203--Clause-lightgrey.svg)](./LICENSE)
 
 ![](https://raw.githubusercontent.com/openNAMU/openNAMU/beta/.github/logo.png)

+ 2 - 23
route/main_func_easter_egg.py

@@ -3,23 +3,6 @@ from .tool.func import *
 def main_func_easter_egg():
     with get_db_connect() as conn:
         curs = conn.cursor()
-        
-        random_n = random.randrange(0, 8)
-        select_list = [
-            'PWD0ZbR7AOY', # TH06   - Shanghai Teahouse ~ Chinese Tea
-            'HoU29ljOmTE', # TH10.5 - Flawless Clothing of Celestials
-            'PR2vUm-Ald8', # TH06   - U.N. Owen Was Her
-            'opZoEmsu_Lo', # TH09   - Flowering Night
-            'txZFFTusSvw', # TH08   - Reach for the Moon ~ Immortal Smoke
-            'Ixq9xL2tvRU', # TH07   - Phantom Ensemble
-            '-3IAx_r4Au0', # TH17   - Entrusting This World to Idols ~ Idolatrize World
-            'wObZkycA6sc', # TH11   - Last Remote
-            'hZxYLa97gDg', # TH12   - Emotional Skyscraper ~ Cosmic Mind
-            'hwn2kw4eFJM', # TH07   - Border of Life
-            'wX2t_8HOtiY', # TH08   - Voyage 1969
-            'tLQjcf45fKE', # TH07   - Necrofantasia
-            # Remix by NyxTheShield
-        ]
 
         ip = ip_check()
         if ip_or_user(ip) == 0:
@@ -27,9 +10,5 @@ def main_func_easter_egg():
             if not curs.fetchall():
                 curs.execute(db_change('insert into user_set (name, id, data) values ("get_🥚", ?, "Y")'), [ip])
                 conn.commit()
-
-        return easy_minify(flask.render_template(skin_check(),
-            imp = ['Easter Egg', wiki_set(), wiki_custom(), wiki_css([0, 0])],
-            data = '<iframe width="640" height="360" src="https://www.youtube.com/embed/' + select_list[random_n] + '" frameborder="0" allowfullscreen></iframe>',
-            menu = [['manager', load_lang('return')]]
-        ))
+    
+        return redirect('/easter_egg_go')

+ 32 - 0
route_go/main_easter_egg.go

@@ -0,0 +1,32 @@
+package main
+
+import (
+	"C"
+	"math/rand"
+)
+
+//export Do
+func Do() *C.char {
+	select_list := []string{
+		"PWD0ZbR7AOY",
+		"HoU29ljOmTE",
+		"PR2vUm-Ald8",
+		"opZoEmsu_Lo",
+		"txZFFTusSvw",
+		"Ixq9xL2tvRU",
+		"-3IAx_r4Au0",
+		"wObZkycA6sc",
+		"hZxYLa97gDg",
+		"hwn2kw4eFJM",
+		"wX2t_8HOtiY",
+		"tLQjcf45fKE",
+		// Remix by NyxTheShield
+	}
+	select_str := select_list[rand.Intn(len(select_list)-1)]
+
+	return C.CString("<iframe width=\"640\" height=\"360\" src=\"https://www.youtube.com/embed/" + select_str + "\" frameborder=\"0\" allowfullscreen></iframe>")
+}
+
+func main() {
+
+}

+ 75 - 0
route_go/main_easter_egg.h

@@ -0,0 +1,75 @@
+/* Code generated by cmd/cgo; DO NOT EDIT. */
+
+/* package command-line-arguments */
+
+
+#line 1 "cgo-builtin-export-prolog"
+
+#include <stddef.h> /* for ptrdiff_t below */
+
+#ifndef GO_CGO_EXPORT_PROLOGUE_H
+#define GO_CGO_EXPORT_PROLOGUE_H
+
+#ifndef GO_CGO_GOSTRING_TYPEDEF
+typedef struct { const char *p; ptrdiff_t n; } _GoString_;
+#endif
+
+#endif
+
+/* Start of preamble from import "C" comments.  */
+
+
+
+
+/* End of preamble from import "C" comments.  */
+
+
+/* Start of boilerplate cgo prologue.  */
+#line 1 "cgo-gcc-export-header-prolog"
+
+#ifndef GO_CGO_PROLOGUE_H
+#define GO_CGO_PROLOGUE_H
+
+typedef signed char GoInt8;
+typedef unsigned char GoUint8;
+typedef short GoInt16;
+typedef unsigned short GoUint16;
+typedef int GoInt32;
+typedef unsigned int GoUint32;
+typedef long long GoInt64;
+typedef unsigned long long GoUint64;
+typedef GoInt64 GoInt;
+typedef GoUint64 GoUint;
+typedef __SIZE_TYPE__ GoUintptr;
+typedef float GoFloat32;
+typedef double GoFloat64;
+typedef float _Complex GoComplex64;
+typedef double _Complex GoComplex128;
+
+/*
+  static assertion to make sure the file is being used on architecture
+  at least with matching size of GoInt.
+*/
+typedef char _check_for_64_bit_pointer_matching_GoInt[sizeof(void*)==64/8 ? 1:-1];
+
+#ifndef GO_CGO_GOSTRING_TYPEDEF
+typedef _GoString_ GoString;
+#endif
+typedef void *GoMap;
+typedef void *GoChan;
+typedef struct { void *t; void *v; } GoInterface;
+typedef struct { void *data; GoInt len; GoInt cap; } GoSlice;
+
+#endif
+
+/* End of boilerplate cgo prologue.  */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern char* Do();
+
+#ifdef __cplusplus
+}
+#endif

BIN
route_go/main_easter_egg.so