diff --git a/API/main.py b/API/main.py index f380a13..70ad027 100644 --- a/API/main.py +++ b/API/main.py @@ -333,7 +333,7 @@ def get_events(): def main(): init_db() - app.run() + app.run('0.0.0.0') if __name__ == '__main__': diff --git a/Mobile/app/src/main/java/com/example/russionroadsapp/API.kt b/Mobile/app/src/main/java/com/example/russionroadsapp/API.kt new file mode 100644 index 0000000..6050bbb --- /dev/null +++ b/Mobile/app/src/main/java/com/example/russionroadsapp/API.kt @@ -0,0 +1,31 @@ +package com.example.russionroadsapp + +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.GlobalScope +import kotlinx.coroutines.launch +import java.io.BufferedReader +import java.io.InputStreamReader +import java.net.HttpURLConnection +import java.net.URL + +object API { + private val API_BASE_URL = "http://192.168.0.124:5000" + + fun getNews(onFinish: (String) -> Unit) { + GlobalScope.launch(Dispatchers.IO) { + val reqURL = URL("$API_BASE_URL/rss") + val connection = reqURL.openConnection() as HttpURLConnection + connection.requestMethod = "GET" + + if (connection.responseCode == 200) { + val resp = BufferedReader( + InputStreamReader(connection.inputStream) + ).use { it.readText() } + + onFinish(resp) + } else { + onFinish("Error") + } + } + } +} diff --git a/MyApplication/app/src/main/AndroidManifest.xml b/MyApplication/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..f3ba880 --- /dev/null +++ b/MyApplication/app/src/main/AndroidManifest.xml @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + \ No newline at end of file