Spaces:
Sleeping
Sleeping
Create main.py
Browse files
main.py
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from fastapi import FastAPI
|
2 |
+
from fastapi.responses import HTMLResponse
|
3 |
+
from llama_cpp.server.app import create_app, Settings
|
4 |
+
import tomli
|
5 |
+
|
6 |
+
# Load the configuration from the config.toml file
|
7 |
+
with open("config.toml", "rb") as f:
|
8 |
+
settings = tomli.load(f)
|
9 |
+
settings = Settings(**settings)
|
10 |
+
|
11 |
+
app = create_app(settings=settings)
|
12 |
+
|
13 |
+
# Extend the app with your custom route
|
14 |
+
@app.get('/', response_class=HTMLResponse)
|
15 |
+
def custom_index_route():
|
16 |
+
html_content = """
|
17 |
+
<html>
|
18 |
+
<body>
|
19 |
+
<iframe src="https://MatrixStudio-Qwen-7B-gguf-API.hf.space" frameborder="0" width="100%" height="100%"></iframe>
|
20 |
+
</body>
|
21 |
+
</html>
|
22 |
+
"""
|
23 |
+
return HTMLResponse(content=html_content)
|
24 |
+
|
25 |
+
if __name__ == '__main__':
|
26 |
+
import uvicorn
|
27 |
+
uvicorn.run(app, host='0.0.0.0', port=8000)
|