-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_server_simple.py
More file actions
57 lines (44 loc) · 1.36 KB
/
test_server_simple.py
File metadata and controls
57 lines (44 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/env python3
"""Simple server test to verify basic functionality"""
import sys
sys.path.insert(0, '.')
print("Testing FasterAPI server...")
from fasterapi import App
app = App(port=8080)
@app.get("/json")
def json_test(req, res):
return {"message": "Hello, World!"}
@app.get("/plaintext")
def plaintext_test(req, res):
res.content_type("text/plain").text("Hello, World!").send()
print("✅ Routes registered successfully")
print("🚀 Starting server on http://localhost:8080")
print()
print("Test endpoints:")
print(" http://localhost:8080/json")
print(" http://localhost:8080/plaintext")
print()
# Check if server has necessary methods
print(f"Server has start(): {hasattr(app.server, 'start')}")
print(f"Server has stop(): {hasattr(app.server, 'stop')}")
print(f"Server has is_running(): {hasattr(app.server, 'is_running')}")
print()
# Try to start
try:
print("Calling app.server.start()...")
app.server.start()
print("✅ Server started")
import time
print("Waiting to check if server is running...")
time.sleep(1)
if app.server.is_running():
print("✅ Server is running!")
else:
print("❌ Server is not running")
print("\nStopping server...")
app.server.stop()
print("✅ Server stopped")
except Exception as e:
print(f"❌ Error: {e}")
import traceback
traceback.print_exc()