0

I implemented load, parse, query, lookup and indexes, but now when I try to run the program and open up my Web Server from the CS50 IDE, I get the error message quoted in the title of this post.

Here's the sandbox link for the Check50 test results.

Here's the code for indexes:

char* indexes(const char* path)
{
    char* index_html = strcat((char*)path, "/index.html");
    char* index_php = strcat((char*)path, "/index.php");
    if (realpath(path, index_html) != NULL)
    {
        return index_html;
    }
    else if (realpath(path, index_php) != NULL)
    {
        return index_php;
    }
    return NULL;
}

Looking at the error messages in Check50, I'm thinking that the problem is in indexes. That's why I'm only posting that. If anyone suspects that there might be a problem somewhere else, please let me know.

0

If the server accesses the indexes function, path ends with /test/, so you should copy in path only "index.html" etc ... On the other hand I do not think the realpath () function works well, you have an interesting function called access () with the F_OK macro very easy to use, and it only checks if the file exists. I hope that helps.

EDIT:

// declare pointers to index
// reserve enough memory
// strcpy path in the malloc pointer
// strcat in the malloc pointer
// check that path / index.html exists
   // if it exists we return the pointer malloc
// free pointer

Same for the other pointer to .php Please, if you have more questions, start a new thread

18
  • I'm getting the error message: "Using /home/ubuntu/workspace/pset6/public for server's root Port 8080 already in use Stopping server ~/workspace/pset6/ $ ./server 80 ./public Stopping server ~/workspace/pset6/ $ ./server 80 ./public/test/index.html Stopping server" – Osman Zakir Dec 1 '16 at 18:40
  • how do I turn the Web Server off after I've done something in it? Because that might be part of the reason for this – Osman Zakir Dec 1 '16 at 18:41
  • never mind, I got it. And it works, too. – Osman Zakir Dec 1 '16 at 18:57
  • okay, no, it doesn't work. Never mind. I'm still getting the same errors on Check50. I'll post the code on pastebin this time. – Osman Zakir Dec 1 '16 at 19:07
  • link: pastebin.com/3zfy6fvm – Osman Zakir Dec 1 '16 at 19:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .