FileSystemException: Cannot open file, path = 'file:///usr/local/server/src/static/index.html' (OS E
- 1
- Self Hosted
- Functions

Just copied the util.dart file

To my code

And pushed using the CLI

What's your folder structure and what's the function in your appwrite.json?


"projectId": "64fff1b78429690cbb74",
"projectName": "windope",
"functions": [
{
"$id": "65480141667102a7bf37",
"name": "site",
"runtime": "dart-2.17",
"execute": [],
"events": [],
"schedule": "",
"timeout": 15,
"enabled": true,
"logging": true,
"entrypoint": "lib/main.dart",
"commands": "dart pub get",
"ignore": [
".packages",
".dart_tool"
],
"path": "./"
}
]
}

final String _dirname = Platform.script.toFilePath();
final String staticFolder = '${Uri.file(_dirname).resolve('../static')}';
/// Throws an error if any of the keys are missing from the object
/// @param obj - The object to check
/// @param keys - The list of keys to check for
/// @throws Exception
void throwIfMissing(Map<String, dynamic> obj, List<String> keys) {
final missing = <String>[];
for (var key in keys) {
if (!obj.containsKey(key) || obj[key] == null) {
missing.add(key);
}
}
if (missing.isNotEmpty) {
throw Exception('Missing required fields: ${missing.join(', ')}');
}
}
/// Returns the contents of a file in the static folder
/// @param fileName - The name of the file to read
/// @returns Contents of static/{fileName}
Future<String> getStaticFile(String fileName) {
return File('index.html').readAsString();
}

even I have done this dart return File('index.html').readAsString();

Look at the files in the template. The html file should be in a folder named static

yes I have done that only in the begning

still same error

What?

return File('index.html').readAsString();
}
``` have hardcored the file path

Have you tried doing it as the template does?

In the starting I have followed the same file structure

Yes I have

getting the same error

Please share what you have after you change it to what the template did

its simply serves a index.html on GET at /


hmm odd...let me check with the team

yes I am contributing to appwrite/template ,

pull request just pending on this @Drake

For now, you might want to put a string in your code rather than trying to have a static file

I'm experiencing the same problem. any solution?
Error:- PathNotFoundException: Cannot open file, path = 'file:///usr/local/server/src/static/index.html' (OS Error: No such file or directory, errno = 2)
Recommended threads
- Is it possible to make a direct query in...
I have a self-host, and I have a table with several hundred thousand records. I need to quickly get the number of items based on filters, and the only way to do...
- Error when executing a function from pos...
I am trying to make a post request from postman to my function https://fra.cloud.appwrite.io/v1/functions/functionid/executions on the same body when i put from...
- migration self hosted from 1.7.4 to 1.8....
just did the basic migration on a selfhosted verion and got internal server error: for the membership request:https://134.209.23.92/v1/teams/6550c866911e5fbb2c...
