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
- Appwrite Functions Generally Down?
We are getting customer support requests, that our service is down. We tried to pinpoint it, and we can't see any logs of any appwrite cloud function in the pas...
- Unable to migrate the project to self ho...
The Continue button is disabled in the migration modal. Unable to migrate the project. In both local and cloud appwrite 1.7.4
- Why a REST client keeps getting "The cur...
Why a REST client or API call keeps getting "The current user is not authorized to perform the requested action" even if the roles are configured correctly? Wha...
