hlohaus commited on
Commit
6c19d0a
·
1 Parent(s): 32293b9

Add application file

Browse files
Files changed (2) hide show
  1. app.py +33 -0
  2. requirements.txt +19 -0
app.py ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import g4f.api
2
+ import g4f.Provider
3
+
4
+ g4f.Provider.__map__["Feature"] = g4f.Provider.BackendApi
5
+
6
+ def create_app():
7
+ g4f.debug.logging = True
8
+ g4f.api.AppConfig.gui = True
9
+ g4f.api.AppConfig.demo = True
10
+
11
+ app = FastAPI()
12
+
13
+ # Add CORS middleware
14
+ app.add_middleware(
15
+ g4f.api.CORSMiddleware,
16
+ allow_origin_regex=".*",
17
+ allow_credentials=True,
18
+ allow_methods=["*"],
19
+ allow_headers=["*"],
20
+ )
21
+
22
+ api = g4f.api.Api(app)
23
+
24
+ api.register_routes()
25
+ api.register_authorization()
26
+ api.register_validation_exception_handler()
27
+
28
+ gui_app = g4f.api.WSGIMiddleware(g4f.api.get_gui_app(g4f.api.AppConfig.demo))
29
+ app.mount("/", gui_app)
30
+
31
+ return app
32
+
33
+ app = create_app()
requirements.txt ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ g4f
2
+ Flask-Limiter
3
+ requests
4
+ pycryptodome
5
+ aiohttp
6
+ certifi
7
+ duckduckgo-search>=6.3.7
8
+ nest_asyncio
9
+ werkzeug
10
+ pillow
11
+ fastapi
12
+ uvicorn
13
+ flask
14
+ brotli
15
+ beautifulsoup4
16
+ aiohttp_socks
17
+ cryptography
18
+ python-multipart
19
+ pypdf2