Moonfanz commited on
Commit
82d9700
·
verified ·
1 Parent(s): ce63f30

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +40 -2
app.py CHANGED
@@ -1,5 +1,5 @@
1
 
2
- from flask import Flask, request, jsonify, Response, stream_with_context
3
  import google.generativeai as genai
4
  import json
5
  from datetime import datetime
@@ -72,7 +72,45 @@ GEMINI_MODELS = [
72
  {"id": "gemini-2.0-exp"},
73
  {"id": "gemini-2.0-pro-exp"},
74
  ]
75
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
76
  @app.route('/hf/v1/chat/completions', methods=['POST'])
77
  def chat_completions():
78
  global current_api_key
 
1
 
2
+ from flask import Flask, request, jsonify, Response, stream_with_context, render_template_string
3
  import google.generativeai as genai
4
  import json
5
  from datetime import datetime
 
72
  {"id": "gemini-2.0-exp"},
73
  {"id": "gemini-2.0-pro-exp"},
74
  ]
75
+ @app.route('/')
76
+ def index():
77
+ main_content = "Moonfanz Gemini" # 替换成您的实际动态内容
78
+ html_template = """
79
+ <!DOCTYPE html>
80
+ <html>
81
+ <head>
82
+ <meta charset="utf-8">
83
+ <script>
84
+ function copyToClipboard(text) {
85
+ var textarea = document.createElement("textarea");
86
+ textarea.textContent = text;
87
+ textarea.style.position = "fixed";
88
+ document.body.appendChild(textarea);
89
+ textarea.select();
90
+ try {
91
+ return document.execCommand("copy");
92
+ } catch (ex) {
93
+ console.warn("Copy to clipboard failed.", ex);
94
+ return false;
95
+ } finally {
96
+ document.body.removeChild(textarea);
97
+ }
98
+ }
99
+ function copyLink(event) {
100
+ event.preventDefault();
101
+ const url = new URL(window.location.href);
102
+ const link = url.protocol + '//' + url.host + '/v1';
103
+ copyToClipboard(link);
104
+ alert('链接已复制: ' + link);
105
+ }
106
+ </script>
107
+ </head>
108
+ <body>
109
+ {{ main_content }}<br/><br/>完全开源、免费且禁止商用<br/><br/>点击复制反向代理: <a href="v1" onclick="copyLink(event)">Copy Link</a><br/>填入OpenAI API反向代理,酒馆需打开Show "External" models,<br/><br/>教程与FAQ: <a href="https://example.com" target="FAQ">Rentry</a> | <a href="https://discord.com/invite/B7Wr25Z7BZ" target="FAQ">Discord</a><br/><br/><br/>
110
+ </body>
111
+ </html>
112
+ """
113
+ return render_template_string(html_template, main_content=main_content)
114
  @app.route('/hf/v1/chat/completions', methods=['POST'])
115
  def chat_completions():
116
  global current_api_key