-1

I have a problem when i launch the perfect http server.

The file "/" was not found

I use Xcode 7.3.1 on MAC OS 10.11. I followed exactly the same steps in this tutorial

This my screen message after executing the server This my screen message after executing the server

Stephan Vierkant
  • 9,674
  • 8
  • 61
  • 97
BriniH
  • 35
  • 11

2 Answers2

1

In that tutorial, there is no default route, so you would need to make a request to /posts in order to get a response. If you work thru the tutorial, you will see how to post data to the server and retrieve a response.

Tim Taplin
  • 11
  • 1
  • 2
  • Thanks for responding but the section building the service is suffisant for me. i don't want to interact with sql server. i want to pass different http command to get different http response through the GET and POST. For exemple : if i send this command localhost:8181/posts/sayHello i get a http response "Hello" – BriniH Jun 03 '16 at 06:44
  • There is a project called URL Routing in the Perfect Examples repository which shows several additional examples of route handling. Here is one suggestion of how you could set up your response: – Tim Taplin Jun 03 '16 at 15:00
  • `Routing.Routes["POST", "/posts/{request}"] = { _ in return PostRequestHandler() } class PostRequestHandler: RequestHandler { func handleRequest(request: WebRequest, response: WebResponse) { switch request.urlVariables["request"] { case "sayHello"?: response.appendBodyString("Hello") default: response.appendBodyString("request not handled") } response.requestCompletedCallback() } }` this will handle Posts to the path, Get will not be handled, you can leave that part of the route off to get both types – Tim Taplin Jun 03 '16 at 15:11
0

For me the reason was: I called the function not

PerfectServerModuleInit

but this way: public func perfectServerModuleInit()

So perfect couldn't find it.

Naloiko Eugene
  • 2,453
  • 1
  • 28
  • 18