質問編集履歴

3

解決した

2022/01/24 02:51

投稿

volvox
volvox

スコア0

test CHANGED
@@ -1 +1 @@
1
- SyntaxError: 'return' outside function.の解決方法
1
+ 【解決済み】SyntaxError: 'return' outside function.の解決方法
test CHANGED
@@ -39,3 +39,20 @@
39
39
 
40
40
  よろしくお願いいたします。
41
41
 
42
+
43
+ 【追記】
44
+ 理由はよくわかりませんが、以下のように入力したら直りました。
45
+
46
+ ご回答いただきまして、ありがとうございました。
47
+
48
+ ```
49
+ from flask import Flask
50
+
51
+ app = Flask(__name__)
52
+
53
+ @app.route("/")
54
+ def hello_world():
55
+ return "hello.world"
56
+ quit()
57
+ ```
58
+

2

内容の変更

2022/01/16 17:52

投稿

volvox
volvox

スコア0

test CHANGED
@@ -1 +1 @@
1
- Error: Failed to parse 'hello.py' as an attribute name or function call.の解決方法
1
+ SyntaxError: 'return' outside function.の解決方法
test CHANGED
@@ -12,28 +12,13 @@
12
12
 
13
13
  ### 発生している問題・エラーメッセージ
14
14
 
15
- VScodeのターミナル(cmd)で
16
- ```ここに言語を入力
17
- set FLASK_APP=hello:hello.py
18
- ```
19
- と入力し、
20
- ```ここに言語を入力
21
- flask run
22
- ```
23
- とすると、以下のエラーメッセージが必ず出てきます。
24
15
 
25
16
  **エラーメッセージ**
26
-
17
+ ターミナル(python)に以下のように表示されます。
27
18
  ```
28
- * Serving Flask app 'hello:hello.py' (lazy loading)
29
- * Environment: production
19
+ return "hello.world"
30
- WARNING: This is a development server. Do not use it in a production deployment.
31
- Use a production WSGI server instead.
32
- * Debug mode: off
33
- Usage: flask run [OPTIONS]
34
- Try 'flask run --help' for help.
20
+ File "<stdin>", line 1
35
-
36
- Error: Failed to parse 'hello.py' as an attribute name or function call.
21
+ SyntaxError: 'return' outside function
37
22
  ```
38
23
  なお、該当部分には以下のようなコードを書きました。
39
24
 
@@ -48,7 +33,8 @@
48
33
 
49
34
  @app.route("/")
50
35
  def hello_world():
36
+
51
- return "<p>Hello, World!</p>"
37
+ return "hello.world"
52
38
  ```
53
39
 
54
40
  よろしくお願いいたします。

1

誤字訂正

2022/01/16 16:51

投稿

volvox
volvox

スコア0

test CHANGED
File without changes
test CHANGED
@@ -51,11 +51,5 @@
51
51
  return "<p>Hello, World!</p>"
52
52
  ```
53
53
 
54
- ### 試したこと
54
+ よろくお願いいします。
55
55
 
56
-
57
-
58
- ### 補足情報(FW/ツールのバージョンなど)
59
-
60
- ターミナルにzshが見当たらず、
61
-