Spaces:
Runtime error
Runtime error
Update server.py
Browse files
server.py
CHANGED
@@ -1,32 +1,50 @@
|
|
1 |
-
import uvicorn
|
2 |
-
import os
|
3 |
-
import requests
|
4 |
-
import json
|
5 |
-
import base64
|
6 |
-
import re
|
7 |
-
import logging
|
8 |
-
from typing import Union
|
9 |
-
from base64 import b64decode
|
10 |
-
|
11 |
-
from fastapi import FastAPI
|
12 |
-
from fastapi.staticfiles import StaticFiles
|
13 |
-
from fastapi.responses import FileResponse
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
32 |
uvicorn.run(app, host="0.0.0.0", port=7860)
|
|
|
1 |
+
import uvicorn
|
2 |
+
import os
|
3 |
+
import requests
|
4 |
+
import json
|
5 |
+
import base64
|
6 |
+
import re
|
7 |
+
import logging
|
8 |
+
from typing import Union
|
9 |
+
from base64 import b64decode
|
10 |
+
|
11 |
+
from fastapi import FastAPI
|
12 |
+
from fastapi.staticfiles import StaticFiles
|
13 |
+
from fastapi.responses import FileResponse
|
14 |
+
|
15 |
+
from pydantic import BaseModel
|
16 |
+
from loguru import logger
|
17 |
+
from pyngrok import ngrok
|
18 |
+
import nest_asyncio
|
19 |
+
|
20 |
+
logging.basicConfig(level=logging.ERROR)
|
21 |
+
|
22 |
+
app = FastAPI(
|
23 |
+
title="HellBot",
|
24 |
+
version="1.0.2",
|
25 |
+
contact={
|
26 |
+
"name": "๐สสโึ๐",
|
27 |
+
"url": "https://t.me/UFoPinfo",
|
28 |
+
},
|
29 |
+
docs_url=None, redoc_url="/"
|
30 |
+
)
|
31 |
+
|
32 |
+
class UserRequestIn(BaseModel):
|
33 |
+
text: str
|
34 |
+
|
35 |
+
@app.post("/test")
|
36 |
+
def index(request: UserRequestIn):
|
37 |
+
logger.debug(request)
|
38 |
+
return {"ok": True}
|
39 |
+
|
40 |
+
ngrok_tunnel = ngrok.connect(7860)
|
41 |
+
|
42 |
+
ngrok_tunnel
|
43 |
+
|
44 |
+
@app.get("/")
|
45 |
+
def HellBot():
|
46 |
+
return {"message": "running"}
|
47 |
+
|
48 |
+
if __name__ == "__main__":
|
49 |
+
nest_asyncio.apply()
|
50 |
uvicorn.run(app, host="0.0.0.0", port=7860)
|